scrollintoview animation

In most modern browsers (Chrome and Firefox, but not Safari, UC, or IE) you can pass options in an object to .scrollIntoView(). Try this: elm.scrollIntoView({ behavior: ‘smooth’, block: ‘center’ }) Other values are behavior: ‘instant’ or block: ‘start’ or block: ‘end’. See https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView

Protractor: Scroll down

You need to wait for the promise to be solved. The following example comes from an open issue browser.executeScript(‘window.scrollTo(0,0);’).then(function () { page.saveButton.click(); }) Update: This is an old question (May of 2014), but still it is getting some visitors. To clarify: window.scrollTo(0, 0) scrolls to the top left corner of the current page. If you … Read more

Detect user scroll down or scroll up in jQuery [duplicate]

To differentiate between scroll up/down in jQuery, you could use: var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? “DOMMouseScroll” : “mousewheel” //FF doesn’t recognize mousewheel as of FF3.x $(‘#yourDiv’).bind(mousewheelevt, function(e){ var evt = window.event || e //equalize event object evt = evt.originalEvent ? evt.originalEvent : evt; //convert to originalEvent if possible var delta = evt.detail ? evt.detail*(-40) : … Read more

Horizontal scrolling with mouse wheel in a div

Try this for horizontal scrolling with mouse wheel. This is pure JavaScript: (function() { function scrollHorizontally(e) { e = window.event || e; var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); document.getElementById(‘yourDiv’).scrollLeft -= (delta * 40); // Multiplied by 40 e.preventDefault(); } if (document.getElementById(‘yourDiv’).addEventListener) { // IE9, Chrome, Safari, Opera document.getElementById(‘yourDiv’).addEventListener(‘mousewheel’, scrollHorizontally, false); // Firefox document.getElementById(‘yourDiv’).addEventListener(‘DOMMouseScroll’, … Read more