Hello everyone,
I'm having a problem with my scrollTo function.
I'm building an horizontal slider scrollable with buttons but there's something weird happening.
Here's an example of what i'm trying to accomplish with working code:
// the function
function goTo() {
e.preventDefault;
TweenLite.to('.wrapper', 1, {
scrollTo: {
x: $('#slide-glasses-2').position().left
},
ease: Power2.easeOut
});
}
// the trigger
$("*[href^='#']").click(function() {
goTo();
});
Point is I don't want to call the function for every button so I wrote this:
// the function
function goTo(target) {
TweenLite.to('.wrapper', 1, {
scrollTo: {
x: $(target).position().left
},
ease: Power2.easeOut
});
}
// the trigger
$("*[href^='#']").click(function() {
var target = $(this).attr('href');
goTo(target);
});
This doesn't work, I mean the click event brings me to the exact slide but without the scrolling animation.
Any suggestions?
Thx everyone