Giter VIP home page Giter VIP logo

reveal.js-plugin-spotlight's Introduction

Spotlight - Reveal.js Plugin

A plugin for Reveal.js allowing to highlight the current mouse position with a spotlight.

It is off by default and you can trigger it with a keyboard press.

Demo

Hardware

I use "Aplic Wireless Mini Air Mouse" as presenter

Installation

Copy

Copy the file spotlight.js into the plugin folder of your reveal.js presentation, i.e. plugin/spotlight.

Dependencies

Add the plugin to the dependencies in your presentation, as below.

Reveal.initialize({
	// ...
	dependencies: [
		// ... 		
		{ src: 'plugin/spotlight/spotlight.js' },
		// ... 
	]
});

Configuration

The plugin can be configured by providing a spotlight option containing an object i.e. with size and other configuration items within the reveal.js initialization options. By default spotlight is toggled by mouse down event. There is no cursor visible by default. You can switch from 'presentation mode' to 'normal mode' by pressing the 'p' key. But you can change this default behaviour.

Reveal.initialize({
	// ...
	spotlight: {

			// size of the spotlight
			size: 60,
			
			// true: Locks the mouse pointer inside the presentation
			// there is by design (Pointer Lock API) no spotlightCursor and presentingCursor 
			// displayed regardless of the configured values 
			lockPointerInsideCanvas: false,

			// toggle spotlight by holding down the mouse key
			toggleSpotlightOnMouseDown: true,

			// the keyCode pressed and held to turn on spotlight, disabled when set to false
			// Problems with this config? Maybe your touchpad is disabled on keypress? 
			spotlightOnKeyPressAndHold: false,

			// choose the cursor when spotlight is on. Maybe "crosshair"?
			spotlightCursor: 'none',

			// choose the cursor when spotlight is off and in presentation mode. Maybe "default"?
			presentingCursor: 'none', 

			// true: initially in presentation mode, will also be ture if this is not set and toggleSpotlightOnMouseDown is true
			initialPresentationMode: true,

			// true: disable selecting in presentation mode
			disablingUserSelect: true,

			// set to a number as transition duration in ms to enable fade in and out, disabled when set to false
			fadeInAndOut: 100,

			// enable pointer mode
			useAsPointer: false,

			// pointer color (If pointer mode enabled)
			pointerColor: 'red'
	},
	keyboard: {	
			// alternative to toggleSpotlightOnMouseDown: 
			// toggle spotlight by pressing key 'c'
			67: function() { RevealSpotlight.toggleSpotlight() },

			// enter/leave presentation mode by pressing key 'p'
			80: function() { 
				RevealSpotlight.togglePresentationMode(); 
			},
	},
	// ...	

Configuration items

size

Default: 60

Configure the size of the spotlight

lockPointerInsideCanvas

Default: false

true: Locks the mouse pointer inside the presentation. Press Esc to undo the lock.

This is very useful especially when you present with a Presenter or a Wireless Air Mouse. Furthermore helpful if you have two screens (i.e. Beamer and Laptopscreen)

This feature relies on the experimental Browser Feature PointerLock

There is by design (Pointer Lock API) no spotlightCursor and presentingCursor displayed regardless of the configured values

toggleSpotlightOnMouseDown

Default: true

Toggle spotlight by holding down the mouse key. And switching to the cursor provided by the configuration item presentingCursor, if configuration item presentingCursorOnlyVisibleWhenSpotlightVisible is true.

spotlightOnKeyPressAndHold

Default: false

false: disabled

keyCode: if this keycode is pressed and held, spotlight is turned on. After releasing the keycode spotlight is turned off

Problems with this config? Maybe your touchpad is disabled on keypress?

presentingCursor

Default: none

Set the cursor value when presentation mode is toggled by togglePresentationMode(). Maybe "default"?

spotlightCursor

Default: none

Set the cursor value when spotlight is displayed. Maybe "crosshair"?

initialPresentationMode

Default: Points to value of toggleSpotlightOnMouseDown

true: starts directly in presentationmode

disablingUserSelect

Default: true

true: disable selecting in presentation mode

fadeInAndOut

Default: false

false: disable fade in and out

number: transition duration in ms to enable fade in and out

useAsPointer

Default: false

Enables a mode where the screen is not dimmed and you can use the mouse as a pointer. While using this option it makes sense to reduce the size to 6

pointerColor

Default: red

Defines the pointer color if configuration item useAsPointer is true.

Methods

toggleSpotlight()

Example:

RevealSpotlight.toggleSpotlight();

If the spotlight is on, it turns it off. If the spotlight is off, it turns it on.

togglePresentationMode()

Example:

RevealSpotlight.togglePresentationMode();

If presentation mode is on, it turns it off and set the cursor to normal. If presentation mode is off, it turns it on and set the cursor to the configuration item presentingCursor.

reveal.js-plugin-spotlight's People

Contributors

cito avatar denniskniep avatar pastleo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

reveal.js-plugin-spotlight's Issues

toggle spotlight on middle key down

mouse's middle key will not invoke text selection. use middle key to toggle spotlight, and left key can serve original use, like text selection or triggering button in slide.

it is posible to config disablingUserSelect to false to enable text selection, but clicking on anchor still not work.

License

A license indication of any kind is missing.

Make Spotlight in speaker notes appear in main slide?

Hey @denniskniep! First of all, thanks for this amazing package ๐Ÿ™

Is there any plan (or is it feasible) to make the spotlight on speaker notes to show up on the main window? If I press 'c' to toggle it in the speaker notes window it creates the spotlight, but it doesn't propagate back to the main window. Thank you ๐Ÿ™‡โ€โ™‚๏ธ

Not working with Reveal.js 3.7.0

Hey,

Thank you for this great idea and sharing !

I can't make it work with Reveal.js 3.7.0. I've put some console logs, so I know it operates in my presentation, but I encounter different problems on different browsers :

  • on Firefox, the spotlight appears on click but does not move with the mouse
  • on Chrome, the spotlight does not appear at all

Here is a sample presentation ('p' for presentation mode) : https://bcouetil.gitlab.io/academy/sample/reveal/reveal-my-asciidoc.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.