容器中的图像 jQuery 滚动条。 (如facebookcropper)无法获取位置值
心里真的很痛。
我有一个 php 图像上传器,一切都很好,并且保存了文件,jquery ajax 在修改后的 html div 中返回图像,其 div 设置如下:
#crop-holder {
width:80px;
height:80px;
margin:10px 10px 20px 10px;
border:1px #c0c0c0 solid;
overflow:hidden;
cursor:move;
}
图像显示正常,我正在使用 jquery rollview 插件:< a href="http://code.google.com/p/jquery-scrollview/" rel="nofollow noreferrer">http://code.google.com/p/jquery-scrollview/
我有尝试在插件中添加几行来存储scrollTop和Left的变量,然后在我的页面中用x和y替换两个隐藏的输入值。然后在 div 中返回的 ajax html 上,我尝试单击按钮(例如)检索两个隐藏输入的值...
这是我添加到插件中的内容(我不是 js 专家!) :
.mouseout(function(){
var _m = this.m;
var lasty = _m.scrollTop();
getElementById("ycord").value = lasty;
var lastx = _m.scrollLeft();
getElementById("xcord").value = lastx;
self.stopgrab();
})
还是没有运气!!
我怎样才能获得scrollTop和scrollLeft并成功地准备它们发送到另一个php脚本!?
:)
谢谢
Having a reallllll mind pain.
I have a php image uploader which is all good and sotring the file and the jquery ajax is returning the image in an ammended html div with a div set up like this:
#crop-holder {
width:80px;
height:80px;
margin:10px 10px 20px 10px;
border:1px #c0c0c0 solid;
overflow:hidden;
cursor:move;
}
The image is viewing fine and I am using the jquery scrollview plugin: http://code.google.com/p/jquery-scrollview/
I have tried adding a few lines to the plugin to store variables of scrollTop and Left and then replacing two hidden input values with x and y in my page. And then on the returned ajax html in the div I am trying to on a button click (for example) retrieve the values of the two hidden inputs....
Heres what i added to the plugin (i'm no js expert!):
.mouseout(function(){
var _m = this.m;
var lasty = _m.scrollTop();
getElementById("ycord").value = lasty;
var lastx = _m.scrollLeft();
getElementById("xcord").value = lastx;
self.stopgrab();
})
Still no luck!!
How can I get the scrollTop and scrollLeft and successfully prepare them for sending onto another php script!?
Thanks:)
stefpretty
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经尝试过 http://jquery-scrollview.googlecode.com 上的示例/svn/trunk/sample.html 但仅限于 safari,因为 firefox 根本不会加载它,而且它不起作用。
如果我理解正确的话,您想使用这些数据来裁剪图像吗?
如果是这样,我建议使用完全其他的 jquery 插件: Jcrop
这个插件特别适合这种工作,在我看来,更好地记录为滚动视图。
I've tried the example on http://jquery-scrollview.googlecode.com/svn/trunk/sample.html but only in safari, because firefox won't load it at all, and it didn't work.
If I understand you correctly, you want to use this data to crop the image?
If so, I would suggest the usage of a completely other jquery plugin: Jcrop
This plugin is especially for this kind of job, and in my opinion much better documented as scrollview.