Skip to content

Instantly share code, notes, and snippets.

@yuchi
Forked from baxtheman/gist:9828154
Last active August 29, 2015 13:57
Show Gist options
  • Save yuchi/9828475 to your computer and use it in GitHub Desktop.
Save yuchi/9828475 to your computer and use it in GitHub Desktop.
<aui:script use="aui-base,anim-base,anim-node-plugin,anim-scroll">
var step = 25;
var scrolling = false;
var list = A.one('.oneshop-portlet-item-browser .list');
var a = new A.Anim({
node: '.oneshop-portlet-item-browser .list',
duration: 0.5
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-up').on('mouseenter', function() {
scrolling = true;
scrollContent("up");
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-up').on('mouseleave', function() {
a.stop();
scrolling = false;
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-down').on('mouseenter', function() {
scrolling = true;
scrollContent("down");
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-down').on('mouseleave', function() {
a.stop();
scrolling = false;
});
function scrollContent(direction) {
var amount = (direction === "up" ? -100 : +100);
console.log(direction);
a.set('to',{
scrollTop: list.attr('scrollTop') + amount
});
a.on('end', function() {
if (scrolling) {
if (list.attr('scrollTop') <= 0) {
scrolling = false;
return;
}
else {
scrollContent(direction);
}
}
});
a.run();
}
</aui:script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment