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.
I use "Aplic Wireless Mini Air Mouse" as presenter
Copy the file spotlight.js
into the plugin folder of your reveal.js presentation, i.e. plugin/spotlight
.
Add the plugin to the dependencies in your presentation, as below.
Reveal.initialize({
// ...
dependencies: [
// ...
{ src: 'plugin/spotlight/spotlight.js' },
// ...
]
});
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();
},
},
// ...
Default: 60
Configure the size of the spotlight
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
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.
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?
Default: none
Set the cursor value when presentation mode is toggled by togglePresentationMode()
. Maybe "default"?
Default: none
Set the cursor value when spotlight is displayed. Maybe "crosshair"?
Default: Points to value of toggleSpotlightOnMouseDown
true: starts directly in presentationmode
Default: true
true: disable selecting in presentation mode
Default: false
false: disable fade in and out
number: transition duration in ms to enable fade in and out
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
Default: red
Defines the pointer color if configuration item useAsPointer
is true
.
Example:
RevealSpotlight.toggleSpotlight();
If the spotlight is on, it turns it off. If the spotlight is off, it turns it on.
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
.