Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to use as pointer #2

Merged
merged 3 commits into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ Reveal.initialize({
presentingCursor: "none",

// true: cursor is always "none" except when spotlight is on.
presentingCursorOnlyVisibleWhenSpotlightVisible: true
presentingCursorOnlyVisibleWhenSpotlightVisible: true,

// enable pointer mode
useAsPointer: true,

// pointer color (If pointer mode enabled)
pointerColor
},
keyboard: {
// alternative to toggleSpotlightOnMouseDown:
Expand Down Expand Up @@ -86,6 +92,15 @@ When you are in presentation mode the cursor is always "none" except when spotli
`false`:
Configuration item `presentingCursor` is always used as cursor value, when you are in presentation mode.

#### useAsPointer
Default: false

Enables a mode where the screen is not dimmed and you can use the mouse as a pointer.

#### pointerColor
Default: `red`

Defines the pointer color if configuration item `useAsPointer` is true.

### Methods

Expand Down
18 changes: 15 additions & 3 deletions spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var RevealSpotlight = window.RevealSpotlight || (function(){
var toggleOnMouseDown;
var presentingCursor;
var presentingCursorOnlyVisibleWhenSpotlightVisible;
var useAsPointer;
var pointerColor;

var drawBoard;
var isSpotlightOn = true;
Expand All @@ -30,6 +32,8 @@ var RevealSpotlight = window.RevealSpotlight || (function(){
var config = Reveal.getConfig().spotlight || {};
spotlightSize = config.size || 60;
presentingCursor = config.presentingCursor || "none";
useAsPointer = config.useAsPointer || false;
pointerColor = config.pointerColor || 'red';

if(config.hasOwnProperty("toggleSpotlightOnMouseDown")){
toggleOnMouseDown = config.toggleSpotlightOnMouseDown;
Expand Down Expand Up @@ -151,12 +155,20 @@ var RevealSpotlight = window.RevealSpotlight || (function(){
maskCanvas.width = canvas.width;
maskCanvas.height = canvas.height;

var maskCtx = maskCanvas.getContext('2d');
maskCtx.fillStyle = "#000000A8";
var maskCtx = maskCanvas.getContext('2d');

// If using as pointer draw a transparent background
var fillStyle = useAsPointer ? "rgba(0, 0, 0, 0)" : "#000000A8"

maskCtx.fillStyle = fillStyle;
maskCtx.fillRect(0, 0, maskCanvas.width, maskCanvas.height);
maskCtx.globalCompositeOperation = 'xor';

maskCtx.fillStyle = "#FFFFFFFF";

// If using as pointer draw specified color or default
var mouseFillStyle = useAsPointer ? pointerColor : "#FFFFFFFF"

maskCtx.fillStyle = mouseFillStyle;
maskCtx.arc(mousePos.x, mousePos.y, spotlightSize, 0, 2 * Math.PI);
maskCtx.fill();

Expand Down