こんにちは世界中の開発者。
シンプルで純粋なJavascript (30行)、JQueryフリー(および他のライブラリ)の ドラッグコントロールスライダーについてサポートが必要です。
私は何ヶ月も検索していて、多くのスクリプトを見つけましたが、-Jqueryが好きではありません。ほとんどのスクリプトには4、5、6のjavascriptが含まれています。小さなスクリプトから多くのことを学びます。
必要なのは、画像の再スケーリング、ページのスクロール、画像の明るさの変更(PHPを使用)などに使用できるシンプルなスライダーだけです。
私はjavascript (2か月)を初めて使用します。これが今のところです。変数名が間違っていることをお詫びします。
<script type="text/javascript">
_item = null;
mouse_x = 0;
drag_x = 0;
function move_init() {
document.onmousemove = _move;
document.onmouseup = _stop;
}
function _stop(){
_item = null;
}
function _move(e){
mouse_x = document.all ? window.event.clientX : e.pageX;
if(_item != null){
_item.style.left = (mouse_x - drag_x) + "px";
}
}
function _move_item(drag)
{
_item = drag;
drag_x = mouse_x - _item.offsetLeft;
}
move_init();
drag.onmousedown=_move_item(); // Agh.. did'nt figure out how this works
</script>
<style type="text/css">
#drag{background:#797979;color:#fff;width:30px;height:15px;position:relative;}
#track{background:red; width:200px;}
</style>
<div id="track"><div id="drag" onmousedown="_move_item(this);" >x</div></div>
私はあなたの助けに感謝します。
私は2012年12月31日にこれを書きました。とても幸せな新年。お互いに仲良くしてください。
ありがとうございました。