Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit by element doesn't work (Vue.js) #19

Closed
adi518 opened this issue May 9, 2017 · 3 comments
Closed

Limit by element doesn't work (Vue.js) #19

adi518 opened this issue May 9, 2017 · 3 comments

Comments

@adi518
Copy link

adi518 commented May 9, 2017

Using this with Vue. Any idea why?

Vue.directive('draggable', {
    bind: function(element) {
        const options = {
            limit: document.getElementById('unlock-slider'),
        };
        const draggable = new Draggable(element, options);
    }
})

And then in my template literal:

<div id="unlock-slider" class="unlock-slider">
    <div class="unlock-link">
        <img :src="signUpSlideButton"> &nbsp;&nbsp;
        <router-link to="/login">
            <b>login</b>
        </router-link>
        &nbsp;&nbsp;
        <img :src="signUpSlideButton">
    </div>
    <img class="unlock-key" :src="signingKeyNormal" v-draggable>
    <img class="unlock-lock" :src="signinLock">
</div>

I've seen the bound demo and it works nicely, so I'm assuming it's something within Vue, but I'm still pretty new to it.

@gonardfreeman
Copy link

Same problem without Vue, so its problem with indicating width of element, because in my case it nicely work with height, but dont want to drag with x axis, i found bad solution use limit object x: [0, x], y: [0, y], but then i can drag it out of container div. here some code to help:

let options = { limit: { x: [0, 870], y: [0, 403], }, limit: container, filterTarget: (e) => { if(e == dragg){ return true; }else{ return false; } }, onDragEnd: (drag, x, y) => { console.log('x=>',x,'y=>',y) } }
<div class="banners_image"> <div id="draggable"> <textarea></textarea> <div class="dragger"></div> </div> </div>

@gonardfreeman
Copy link

sorry! my bad! lookup at your code and findout what im do wrong) the problem was that im declare in css width of text area but not of dragable element, so dragable div was 100% width and there was 0 when you calculating scrollWidth and offsetWidth

@bcherny
Copy link
Owner

bcherny commented May 26, 2017

@adi518 @gonardfreeman is this issue resolved? If not, @adi518 please post a complete repro case and I'll take a look.

@adi518 adi518 closed this as completed Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants