Skip to content

Instantly share code, notes, and snippets.

@tatsuosakurai
Created May 6, 2011 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatsuosakurai/958510 to your computer and use it in GitHub Desktop.
Save tatsuosakurai/958510 to your computer and use it in GitHub Desktop.
ボタン押しっぱなし
<div id="scroller_up"><%= image_tag 'btn_up.jpg' %></div>
<div id="scroller_down"><%= image_tag 'btn_down.jpg' %></div>
<%= javascript_tag do %>
var scroll_up_flg = true;
var scroll_down_flg = true;
Event.observe('scroller_up', 'mousedown', scroll_up_start);
Event.observe('scroller_up', 'mouseup', scroll_up_off);
Event.observe('scroller_down', 'mousedown', scroll_down_start);
Event.observe('scroller_down', 'mouseup', scroll_down_off);
// ▲フラグon
function scroll_up_start(){
scroll_up_flg = true;
var timerID = setInterval(function(){scroll_up_flg ? scroll_up() : clearInterval(timerID)}, 100);
}
// ▲フラグoff
function scroll_up_off(){
scroll_up_flg = false;
}
// ▲スクロール
function scroll_up(){
$('ici_frame').scrollTop -= <%= Setting.scroll_count %>;
}
// ▼フラグon
function scroll_down_start(){
scroll_down_flg = true;
var timerID = setInterval(function(){scroll_down_flg ? scroll_down() : clearInterval(timerID)}, 100);
}
// ▼フラグoff
function scroll_down_off(){
scroll_down_flg = false;
}
// ▼スクロール
function scroll_down(){
$('ici_frame').scrollTop += <%= Setting.scroll_count %>;
}
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment