davetayls / jquery.kinetic

Add kinetic scrolling functionality to a container using mouse or touch devices
http://davetayls.me/jquery.kinetic
MIT License
420 stars 86 forks source link

Help with target filtering #73

Closed ghost closed 9 years ago

ghost commented 10 years ago

Hello, i think that this plugin is quite amazing, but i have a small problem where i need to filter the target i want to scroll and i don't quite understand how to write it in the filterTarget method.

I want to be able to drag only ONE div with a particular id inside the wrapper, not all contents.

davetayls commented 10 years ago

You could just return true/false depending on whether the target has that id. I think this would work

$('#wrapper').kinetic({
    filterTarget: function(target, e){
      return target.id === 'dragger';
    }
});
ghost commented 10 years ago

Thank you! Got it working now.

But i have another problem now. This is can be moved another way(by a slider of sort), but setting the 'left' value. Suppose i moved it to some point. Like left: '-300px'. How do i start kinetic movement from that point? No matter how i try(i tried setting the settings.scrollLeft to 300 or -300), but kinetic always starts movement from it's previous point that it remembered. Is there any way to set it to start from where i want to start?

davetayls commented 9 years ago

not sure off the top of my head but try either setting the scroll position on the wrapper before you initialize .kinetic()