私は、div をドラッグし、同時にページ上の他の div (特に画像) を操作できるようにする jQuery/JavaScript に取り組んでいます。可動 div は基本的に、レンズをシミュレートするための透明な長方形です。私が抱えている問題は、可動 div の下の画像にクリックを渡す方法がわからないことです。CSS の pointer-events プロパティを調べて、可動 div に対して none に設定しようとしましたが、可動 div が可動しなくなります。この可動 div を移動可能に保ちながらクリックを渡す方法はありますか?
編集:私の現在のコードを求めているすべての人に、これが私がこれまでに持っているJavaScriptです:
<script>
$(document).ready(function(){
$('img').click(function(e) {
$(document).unbind('keypress');
$(document).keypress(function(event) {
if ( event.which == 115) {
$(e.target).css('width', '+=25').css('height', '+=25');
};
if ( event.which == 97) {
$(e.target).css('width', '-=25').css('height', '-=25');
};
});
});
//code to drag the lens around with the mouse
$("#draggableLens").mousemove(function(e){
var lensPositionX = e.pageX - 75;
var lensPositionY = e.pageY - 75;
$('.lens').css({top: lensPositionY, left: lensPositionX});
});
});
</script>