jQuery-如何在Chrome中调整鼠标移动图像的大小
jQuery - how to resize image on mousemove in Chrome?
我编写了一个小脚本(JavaScript-jQuery),用于测试依赖于mousemove事件的图像大小调整操作。简而言之,这个想法是点击图像一次,然后拖动光标。图像在每次鼠标移动时都会调整大小,其右下角"跟随"光标。
我遇到的问题是:在你开始移动光标后,调整大小的工作有点不稳定。1-2秒后,它运行得非常平稳。如果停止移动光标一段时间,然后再次移动,也会出现同样的情况。
这个问题似乎只发生在谷歌浏览器中,所以我的第一个想法是它与该浏览器的抗锯齿功能有关。但我不是专家。图像相当大(宽度和高度方面,而不是"KB"方面)
您可以在此处测试此"迷你应用程序":http://picselbocs.com/projects/helsinki-map-application/test.php
下面是代码:
<img src="Helsinki.jpg" id="map" style="width: 526px; height:300px; position: absolute; top:0; left:0" />
<script>
var drag = false;
(function(){
$('#map').on('click',function(){
drag = true;
});
$(document).on('mousemove',function(e){
if (drag)
$('#map').css({ 'height': e.pageY, 'width': e.pageX });
});
})();
</script>
如果有人能为这个问题提供解决方案,我将不胜感激
http://asp-net-by-parijat.blogspot.in/2014/09/aspnet-image-magnifying-effect-with.html!函数($){"严格使用";
var Magnify = function (element, options) {
this.init('magnify', element, options)
}
Magnify.prototype = {
constructor: Magnify
, init: function (type, element, options) {
var event = 'mousemove'
, eventOut = 'mouseleave';
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.nativeWidth = 0
this.nativeHeight = 0
if(!this.$element.parent().hasClass('magnify')) {
this.$element.wrap('<div class="magnify" '>');
this.$element.parent('.magnify').append('<div class="magnify-large" '>');
}
this.$element.siblings(".magnify-large").css("background","url('" + this.$element.attr("src") + "') no-repeat");
this.$element.parent('.magnify').on(event + '.' + this.type, $.proxy(this.check, this));
this.$element.parent('.magnify').on(eventOut + '.' + this.type, $.proxy(this.check, this));
}
相关文章:
- 如何阻止图像移动并根据击键进行操作
- Photoshop脚本:将图像移动到位置x,y
- 使大图像移动的jQuery动画更流畅
- 如何通过按住键而不是重复按下来使图像移动
- 织物.js:将剪切的图像移动到固定的剪切蒙版后面
- 灯箱将图像移动到右下角
- 到达容器边界时停止图像移动
- HTML5画布图像移动闪烁
- 如何在修改后将堆叠的图像移动到另一页
- 垂直滚动鼠标时图像移动
- 旋转木马图像移动到不正确的地方点击事件
- 如何在用户滚动页面时触发图像移动
- 为什么我的代码在布朗运动下旋转针图像移动针的位置?为什么原点的图像是分散的?
- JavaScript在使用DOCTYPE时失去图像移动功能
- 如何使用低分辨率的图像移动
- 将图像移动到鼠标的位置
- 如何使用Javascript点击按钮使图像移动
- 将图像移动到指定的最小值
- 如何让标题随着图像移动
- 使JavaScript图像移动时滚动更平滑