Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
A more effective way of doing this? (Javascript)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Sysode" data-source="post: 333562" data-attributes="member: 25453"><p>Just something quick, wondering if there is a more effective/efficent way of doing this? (It was just something I wrote up quickly)</p><p></p><p>[CODE]$(window).scroll( function(){</p><p> </p><p> $('.featured-work ul.rig li').each( function(i) {</p><p> var objBottom = $(this).position().top + $(this).outerHeight();</p><p> var windowBottom = $(window).scrollTop() + $(window).height();</p><p></p><p> </p><p> if( windowBottom > objBottom ){</p><p> $(this).animate({'opacity':'1'},800);</p><p> }</p><p> });</p><p>});[/CODE]</p><p></p><p>The only improvement I can see is probably assigning a class with the animations and letting the CSS deal with the animating instead of the Javascript.. Leave improvements below (apologies if it's scruffy)</p></blockquote><p></p>
[QUOTE="Sysode, post: 333562, member: 25453"] Just something quick, wondering if there is a more effective/efficent way of doing this? (It was just something I wrote up quickly) [CODE]$(window).scroll( function(){ $('.featured-work ul.rig li').each( function(i) { var objBottom = $(this).position().top + $(this).outerHeight(); var windowBottom = $(window).scrollTop() + $(window).height(); if( windowBottom > objBottom ){ $(this).animate({'opacity':'1'},800); } }); });[/CODE] The only improvement I can see is probably assigning a class with the animations and letting the CSS deal with the animating instead of the Javascript.. Leave improvements below (apologies if it's scruffy) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
A more effective way of doing this? (Javascript)
Top