Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
| Download
Project: KOB1
Views: 16973// Custom reveal.js integration1(function(){2var revealElement = document.querySelector( '.reveal' );3if( revealElement ) {45revealElement.addEventListener( 'mousedown', function( event ) {6var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt';78var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key';9var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 );1011if( event[ modifier ] && !Reveal.isOverview() ) {12event.preventDefault();1314zoom.to({15x: event.clientX,16y: event.clientY,17scale: zoomLevel,18pan: false19});20}21} );2223}24})();2526/*!27* zoom.js 0.3 (modified for use with reveal.js)28* http://lab.hakim.se/zoom-js29* MIT licensed30*31* Copyright (C) 2011-2014 Hakim El Hattab, http://hakim.se32*/33var zoom = (function(){3435// The current zoom level (scale)36var level = 1;3738// The current mouse position, used for panning39var mouseX = 0,40mouseY = 0;4142// Timeout before pan is activated43var panEngageTimeout = -1,44panUpdateInterval = -1;4546// Check for transform support so that we can fallback otherwise47var supportsTransforms = 'WebkitTransform' in document.body.style ||48'MozTransform' in document.body.style ||49'msTransform' in document.body.style ||50'OTransform' in document.body.style ||51'transform' in document.body.style;5253if( supportsTransforms ) {54// The easing that will be applied when we zoom in/out55document.body.style.transition = 'transform 0.8s ease';56document.body.style.OTransition = '-o-transform 0.8s ease';57document.body.style.msTransition = '-ms-transform 0.8s ease';58document.body.style.MozTransition = '-moz-transform 0.8s ease';59document.body.style.WebkitTransition = '-webkit-transform 0.8s ease';60}6162// Zoom out if the user hits escape63document.addEventListener( 'keyup', function( event ) {64if( level !== 1 && event.keyCode === 27 ) {65zoom.out();66}67} );6869// Monitor mouse movement for panning70document.addEventListener( 'mousemove', function( event ) {71if( level !== 1 ) {72mouseX = event.clientX;73mouseY = event.clientY;74}75} );7677/**78* Applies the CSS required to zoom in, prefers the use of CSS379* transforms but falls back on zoom for IE.80*81* @param {Object} rect82* @param {Number} scale83*/84function magnify( rect, scale ) {8586var scrollOffset = getScrollOffset();8788// Ensure a width/height is set89rect.width = rect.width || 1;90rect.height = rect.height || 1;9192// Center the rect within the zoomed viewport93rect.x -= ( window.innerWidth - ( rect.width * scale ) ) / 2;94rect.y -= ( window.innerHeight - ( rect.height * scale ) ) / 2;9596if( supportsTransforms ) {97// Reset98if( scale === 1 ) {99document.body.style.transform = '';100document.body.style.OTransform = '';101document.body.style.msTransform = '';102document.body.style.MozTransform = '';103document.body.style.WebkitTransform = '';104}105// Scale106else {107var origin = scrollOffset.x +'px '+ scrollOffset.y +'px',108transform = 'translate('+ -rect.x +'px,'+ -rect.y +'px) scale('+ scale +')';109110document.body.style.transformOrigin = origin;111document.body.style.OTransformOrigin = origin;112document.body.style.msTransformOrigin = origin;113document.body.style.MozTransformOrigin = origin;114document.body.style.WebkitTransformOrigin = origin;115116document.body.style.transform = transform;117document.body.style.OTransform = transform;118document.body.style.msTransform = transform;119document.body.style.MozTransform = transform;120document.body.style.WebkitTransform = transform;121}122}123else {124// Reset125if( scale === 1 ) {126document.body.style.position = '';127document.body.style.left = '';128document.body.style.top = '';129document.body.style.width = '';130document.body.style.height = '';131document.body.style.zoom = '';132}133// Scale134else {135document.body.style.position = 'relative';136document.body.style.left = ( - ( scrollOffset.x + rect.x ) / scale ) + 'px';137document.body.style.top = ( - ( scrollOffset.y + rect.y ) / scale ) + 'px';138document.body.style.width = ( scale * 100 ) + '%';139document.body.style.height = ( scale * 100 ) + '%';140document.body.style.zoom = scale;141}142}143144level = scale;145146if( document.documentElement.classList ) {147if( level !== 1 ) {148document.documentElement.classList.add( 'zoomed' );149}150else {151document.documentElement.classList.remove( 'zoomed' );152}153}154}155156/**157* Pan the document when the mosue cursor approaches the edges158* of the window.159*/160function pan() {161var range = 0.12,162rangeX = window.innerWidth * range,163rangeY = window.innerHeight * range,164scrollOffset = getScrollOffset();165166// Up167if( mouseY < rangeY ) {168window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) );169}170// Down171else if( mouseY > window.innerHeight - rangeY ) {172window.scroll( scrollOffset.x, scrollOffset.y + ( 1 - ( window.innerHeight - mouseY ) / rangeY ) * ( 14 / level ) );173}174175// Left176if( mouseX < rangeX ) {177window.scroll( scrollOffset.x - ( 1 - ( mouseX / rangeX ) ) * ( 14 / level ), scrollOffset.y );178}179// Right180else if( mouseX > window.innerWidth - rangeX ) {181window.scroll( scrollOffset.x + ( 1 - ( window.innerWidth - mouseX ) / rangeX ) * ( 14 / level ), scrollOffset.y );182}183}184185function getScrollOffset() {186return {187x: window.scrollX !== undefined ? window.scrollX : window.pageXOffset,188y: window.scrollY !== undefined ? window.scrollY : window.pageYOffset189}190}191192return {193/**194* Zooms in on either a rectangle or HTML element.195*196* @param {Object} options197* - element: HTML element to zoom in on198* OR199* - x/y: coordinates in non-transformed space to zoom in on200* - width/height: the portion of the screen to zoom in on201* - scale: can be used instead of width/height to explicitly set scale202*/203to: function( options ) {204205// Due to an implementation limitation we can't zoom in206// to another element without zooming out first207if( level !== 1 ) {208zoom.out();209}210else {211options.x = options.x || 0;212options.y = options.y || 0;213214// If an element is set, that takes precedence215if( !!options.element ) {216// Space around the zoomed in element to leave on screen217var padding = 20;218var bounds = options.element.getBoundingClientRect();219220options.x = bounds.left - padding;221options.y = bounds.top - padding;222options.width = bounds.width + ( padding * 2 );223options.height = bounds.height + ( padding * 2 );224}225226// If width/height values are set, calculate scale from those values227if( options.width !== undefined && options.height !== undefined ) {228options.scale = Math.max( Math.min( window.innerWidth / options.width, window.innerHeight / options.height ), 1 );229}230231if( options.scale > 1 ) {232options.x *= options.scale;233options.y *= options.scale;234235magnify( options, options.scale );236237if( options.pan !== false ) {238239// Wait with engaging panning as it may conflict with the240// zoom transition241panEngageTimeout = setTimeout( function() {242panUpdateInterval = setInterval( pan, 1000 / 60 );243}, 800 );244245}246}247}248},249250/**251* Resets the document zoom state to its default.252*/253out: function() {254clearTimeout( panEngageTimeout );255clearInterval( panUpdateInterval );256257magnify( { x: 0, y: 0 }, 1 );258259level = 1;260},261262// Alias263magnify: function( options ) { this.to( options ) },264reset: function() { this.out() },265266zoomLevel: function() {267return level;268}269}270271})();272273274