Get page scrolling percentage

For some scrolling effects, you may need to know how much percent the page is scrolled. All we need is to know for that is the window height, window top position and document height.

VIEW DEMO   DOWNLOAD FILES

Continue Reading

Smooth page scrolling with TweenMax

Get mousewheel event delta

If you need to get the scroll of the mouse wheel ( mouse event delta ) you can use this script:

$(window).on("mousewheel DOMMouseScroll", function(event){

	var delta = event.originalEvent.wheelDelta/120 || -event.originalEvent.detail/3;
	console.log(delta);

	event.preventDefault();

});

You can also check the jQuery Mousewheel Plugin by Brandon Aaron

Override default jQuery animate() method with GSAP

When it comes to animation, Greensock Animation Platform (GSAP) is one of the most popular platforms around. It is available in both JavaScript and ActionScript with similar syntax and is amazingly fast. Actually, it performs up to 20 times faster than than jQuery’s native animate() method! It is very easy to use it in your project, thanks to greensock’s awesome plugin that overrides default jQuery animate() method and use TweenLight/TweenMax under the hood. All you have to do is to include TweenMax and the plugin and you’re done.

<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/jquery.gsap.min.js"></script>

Once you’ve included the plugin you’re able to use the full power ot TweenMax – it is possible to tween CSS properties such as color, box-shadow, text-shadow, 2D and 3D transforms, background position and many more. GSAP use the same syntax as jQuery and takes care of browser specific code, such as vendor prefixes.

Get current URL with jQuery

Sometimes you need to retrive the current URL of the page. It is very easy in jQuery style:

var currentURL = $(location).attr("href");

 

It can be very useful for social plugins. You can learn more about location object on w3schools.