Skip to content

Instantly share code, notes, and snippets.

@tuki0918
Created March 13, 2014 13:28
Show Gist options
  • Save tuki0918/9528456 to your computer and use it in GitHub Desktop.
Save tuki0918/9528456 to your computer and use it in GitHub Desktop.
// プレゼン用UI
$('.root-pane').remove();
$('.gist.container.js-gist-container').css({'width': '100%'});
$('.column.files').css({'width': '100%'});
$('h3').each(function(){
$(this).css({
'margin-top': $('html').height()+'px',
'padding-top': '30px'
});
});
// 1ページに移動
$('html, body').animate({ scrollTop: $('h3').eq(0).offset().top }, 'fast');
// カウント数
var slide = {count: 0};
// カウント表示
var len = $('h3').length;
var $slideCount = $('<div id="count" />');
$slideCount.html('<span id="slideCount">'+(slide.count+1)+'</span> / <span>'+len+'</span>');
$slideCount.css({
'position':'fixed',
'right': '25px',
'top': '25px',
'z-index': 10000,
'color': '#fff',
'padding': '10px 15px',
'background-color': '#ccc',
'font-size': '1.5em'
});
$('body').append($slideCount);
// キーイベント:「←」prev、「→」next
$(window).keyup(function(e){
if((e.keyCode == 13 || e.keyCode == 37) && slide.count > 0) {
slide.count--;
$('#slideCount').text(slide.count+1);
$('html, body').animate({ scrollTop: $('h3').eq(slide.count).offset().top }, 'fast');
}
if((e.keyCode == 17 || e.keyCode == 39) && slide.count < len-1) {
slide.count++;
$('#slideCount').text(slide.count+1);
$('html, body').animate({ scrollTop: $('h3').eq(slide.count).offset().top }, 'fast');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment