-
-
Save mcsuth/7311533 to your computer and use it in GitHub Desktop.
Revisions
-
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,6 @@ <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> * Using the `window` width and the image width make him walk the screen from left to right. * Clearly, this must be done using Coffee-Script, but feel free to write it out in Javascript and translate it over if that helps. -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 140 additions and 120 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,143 +1,163 @@ # Coffee-Script lab ## Hater's lab | Objective | | :--- | | To reinforce skills familiar in javascript regarding DOM interaction, and successfully translate them into Coffee-Script. *Outline* * Make this into three files. index.html, style.css, and your coffee script file * Grab the [haters.gif](https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif). <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> * You might also throw it in your `assets/images` and use an `<%= img_tag(..)%>` * Using the `window` width and the image width make him walk the screen from left to right. * Clearly, this must be done using Coffee-Script, but feel free to write it out in Javascript and translate it over if that helps. * Try creating a `flip-img` class that you toggle on the img when it reaches the left or right of the screen. * Do this without `jQuery` and using a `window.onLoad`, then re-write it with jQuery. *It's good to refamiliarize yourself every so often with how to do things without jQuery.* A stub for starting your coffee script file ### Try to plan it out like this… maybe in your own words 1.) Wait for the DOM to load. 2.) Grab the *img* from the DOM. 3.) Begin defining a haters function to translate the image to the left or right of the page a.) Create a global variable to keep track of which direction it should be walking b.) Setup conditionals to check that the leftmost position of the *img* isn't greater than the number of pixels between the `window.innerWidth` and `image.width`. i.) Based on those conditionals you should change the walking direction c.) Depending on the direction it's headed, move it left or right some number of pixels. 4.) Run this function every few hundred mili-seconds to animate your haters.gif ### *Some Resources* * [conditionals](http://coffeescript.org/#conditionals) * [functions](http://coffeescript.org/#literals) Get some code in your app ### How might we start implement this? 1.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true # Set some default style img.style.position = "absolute" img.style.left = "0px" # Log that image to the console. console.log img Good start… but remember you have to wait for the `window.onLoad` ### Off to a crawl.. 1.) Wait for DOM to load ### window.onLoad = () -> ### 2.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true # Set some default style img.style.position = "absolute" img.style.left = "0px" # Log that you got the image console.log img ### 3.) Write a haters function ### haters = () -> console.log "I work with the haters.gif ", img ### RECORD THE IMAGE LEFT POSITION… ### ### SOME CONDITIONALS FOR CHECKING LEFT POS ### ### MOVE LEFT OR RIGHT APPROPRIATELY ### # 4.) Call the hater's function every some many mili-seconds.. A start with jQuery ### Up and walking.. 1.) Wait for DOM to load ### $ -> ### Some changes... ### Some ideas for flipping .flip-img { -moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1); filter: FlipH; -ms-filter: "FlipH"; } -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 123 additions and 132 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,152 +1,143 @@ Coffee-Script lab Hater's lab Objective To reinforce skills familiar in javascript regarding DOM interaction, and successfully translate them into Coffee-Script. Outline Make this into three files. index.html, style.css, and your coffee script file Grab the haters.gif. <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> You might also throw it in your assets/images and use an <%= img_tag(..)%> Using the window width and the image width make him walk the screen from left to right. Clearly, this must be done using Coffee-Script, but feel free to write it out in Javascript and translate it over if that helps. Try creating a flip-img class that you toggle on the img when it reaches the left or right of the screen. Do this without jQuery and using a window.onLoad, then re-write it with jQuery. It's good to refamiliarize yourself every so often with how to do things without jQuery. A stub for starting your coffee script file ### Try to plan it out like this… maybe in your own words 1.) Wait for the DOM to load. 2.) Grab the *img* from the DOM. 3.) Begin defining a haters function to translate the image to the left or right of the page a.) Create a global variable to keep track of which direction it should be walking b.) Setup conditionals to check that the leftmost position of the *img* isn't greater than the number of pixels between the `window.innerWidth` and `image.width`. i.) Based on those conditionals you should change the walking direction c.) Depending on the direction it's headed, move it left or right some number of pixels. 4.) Run this function every few hundred mili-seconds to animate your haters.gif ### Some Resources conditionals functions Get some code in your app ### How might we start implement this? 1.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true # Set some default style img.style.position = "absolute" img.style.left = "0px" # Log that image to the console. console.log img Good start… but remember you have to wait for the window.onLoad ### Off to a crawl.. 1.) Wait for DOM to load ### window.onLoad = () -> ### 2.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true # Set some default style img.style.position = "absolute" img.style.left = "0px" # Log that you got the image console.log img ### 3.) Write a haters function ### haters = () -> console.log "I work with the haters.gif ", img ### RECORD THE IMAGE LEFT POSITION… ### ### SOME CONDITIONALS FOR CHECKING LEFT POS ### ### MOVE LEFT OR RIGHT APPROPRIATELY ### # 4.) Call the hater's function every some many mili-seconds.. A start with jQuery ### Up and walking.. 1.) Wait for DOM to load ### $ -> ### Some changes... ### Some ideas for flipping .flip-img { -moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1); filter: FlipH; -ms-filter: "FlipH"; } -
Delmer revised this gist
Nov 4, 2013 . No changes.There are no files selected for viewing
-
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 17 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,9 +38,9 @@ A stub for starting your coffee script file 3.) Begin defining a haters function to translate the image to the left or right of the page a.) Create a global variable to keep track of which direction it should be walking b.) Setup conditionals to check that the leftmost position of the *img* @@ -60,14 +60,22 @@ A stub for starting your coffee script file mili-seconds to animate your haters.gif ### *Some Resources* * [conditionals](http://coffeescript.org/#conditionals) * [functions](http://coffeescript.org/#literals) Get some code in your app ### How might we start implement this? 1.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true @@ -92,7 +100,7 @@ Good start… but remember you have to wait for the `window.onLoad` window.onLoad = () -> ### 2.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] @@ -142,14 +150,3 @@ A start with jQuery Some changes... ### -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,9 +38,9 @@ A stub for starting your coffee script file 3.) Begin defining a haters function to translate the image to the left or right of the page a.) Hmm.. we'll need an outer variable to keep track of which direction it should be walking b.) Setup conditionals to check that the leftmost position of the *img* @@ -66,7 +66,7 @@ Get some code in your app How might we start implement this? 1.) We'll need some outer variables ### img = document.getElementsByTagName("img")[0] @@ -92,7 +92,7 @@ Good start… but remember you have to wait for the `window.onLoad` window.onLoad = () -> ### 2.) We'll need some outer variables ### img = document.getElementsByTagName("img")[0] -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -143,7 +143,7 @@ A start with jQuery ### Some CSS for flipping him around... .flip-img { -moz-transform: scaleX(-1); -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -142,3 +142,14 @@ A start with jQuery Some changes... ### Some CSS for flip-ing him around... .flip-img { -moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1); filter: FlipH; -ms-filter: "FlipH"; } -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 117 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,3 +25,120 @@ * Try creating a `flip-img` class that you toggle on the img when it reaches the left or right of the screen. * Do this without `jQuery` and using a `window.onLoad`, then re-write it with jQuery. *It's good to refamiliarize yourself every so often with how to do things without jQuery.* A stub for starting your coffee script file ### Try to plan it out like this… maybe in your own words 1.) Wait for the DOM to load. 2.) Grab the *img* from the DOM. 3.) Begin defining a haters function to translate the image to the left or right of the page a.) Create a global variable to keep track of which direction it should be walking b.) Setup conditionals to check that the leftmost position of the *img* isn't greater than the number of pixels between the `window.innerWidth` and `image.width`. i.) Based on those conditionals you should change the walking direction c.) Depending on the direction it's headed, move it left or right some number of pixels. 4.) Run this function every few hundred mili-seconds to animate your haters.gif ### Get some code in your app ### How might we start implement this? 1.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true # Set some default style img.style.position = "absolute" img.style.left = "0px" # Log that image to the console. console.log img Good start… but remember you have to wait for the `window.onLoad` ### Off to a crawl.. 1.) Wait for DOM to load ### window.onLoad = () -> ### 2.) We'll need some global variables ### img = document.getElementsByTagName("img")[0] walkRight = true # Set some default style img.style.position = "absolute" img.style.left = "0px" # Log that you got the image console.log img ### 3.) Write a haters function ### haters = () -> console.log "I work with the haters.gif ", img ### RECORD THE IMAGE LEFT POSITION… ### ### SOME CONDITIONALS FOR CHECKING LEFT POS ### ### MOVE LEFT OR RIGHT APPROPRIATELY ### # 4.) Call the hater's function every some many mili-seconds.. A start with jQuery ### Up and walking.. 1.) Wait for DOM to load ### $ -> ### Some changes... ### -
Delmer revised this gist
Nov 4, 2013 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # Coffee-Script lab ## Hater's lab @@ -11,10 +11,17 @@ *Outline* * start a new rails project * Grab the [haters.gif](https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif). <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> * You might also throw it in your `assets/images` and use an `<%= img_tag(..)%>` * Using the `window` width and the image width make him walk the screen from left to right. * Clearly, this must be done using Coffee-Script, but feel free to write it out in Javascript and translate it over if that helps. * Try creating a `flip-img` class that you toggle on the img when it reaches the left or right of the screen. * Do this without `jQuery` and using a `window.onLoad`, then re-write it with jQuery. *It's good to refamiliarize yourself every so often with how to do things without jQuery.* -
Delmer created this gist
Nov 4, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ # Coffee-Script lab ## Hater's/8-ball lab | Objective | | :--- | | To reinforce skills familiar in javascript regarding DOM interaction, and successfully translate them into Coffee-Script. *Outline* * Grab the [haters.gif](https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif). <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> <img src="https://s3-us-west-2.amazonaws.com/haters.gif/haters.gif"></img> *