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

选区可以随意拖动 #19

Open
PENG199 opened this issue Jan 26, 2018 · 2 comments
Open

选区可以随意拖动 #19

PENG199 opened this issue Jan 26, 2018 · 2 comments

Comments

@PENG199
Copy link

PENG199 commented Jan 26, 2018

选区可以随意拖动,甚至可以拖动到图片外面。并没有限制只能在图片大小的范围的进行拖动。希望能修复。

@bullyork
Copy link

@PENG199 master的代码可以用,npm没有更新,不过master的代码需要改一下。
alloy-crop.js文件中

pressMove: function (evt) {
    var cr = self.img.getBoundingClientRect();
    var boxOffY = (document.documentElement.clientHeight - self.height)/2;
    if((boxOffY - cr.top - evt.deltaY >= 0) && (cr.bottom + evt.deltaY - boxOffY>= self.height)){
        self.img.translateY += evt.deltaY;
    }
    var boxOffX = (document.documentElement.clientWidth - self.width)/2;
    if((cr.left + evt.deltaX <= boxOffX) && (cr.right + evt.deltaX - boxOffX >= self.width)){
        self.img.translateX += evt.deltaX;  
    }
    evt.preventDefault();
}

@dntzhang
Copy link

npm 刚发布了~~

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