Skip to content

Commit

Permalink
Streamline variable declarations further
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed May 30, 2024
1 parent c035b46 commit 1eb10c5
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/jcanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,6 @@ function _closePath(
ctx: CanvasRenderingContext2D,
params: JCanvasObject
) {
let data;

// Optionally close path
if (params.closed) {
ctx.closePath();
Expand Down Expand Up @@ -489,7 +487,7 @@ function _closePath(
// Mask shape if chosen
if (params.mask) {
// Retrieve canvas data
data = _getCanvasData(canvas);
const data = _getCanvasData(canvas);
_enableMasking(ctx, data, params);
}
}
Expand Down Expand Up @@ -874,13 +872,12 @@ $.fn.getEventHooks = function getEventHooks() {
// Set event hooks for the selected canvases
$.fn.setEventHooks = function setEventHooks(eventHooks) {
const $canvases = this;
let data;
for (let e = 0; e < $canvases.length; e += 1) {
const canvas = $canvases[e];
if (!_isCanvas(canvas)) {
continue;
}
data = _getCanvasData(canvas);
const data = _getCanvasData(canvas);
extendObject(data.eventHooks, eventHooks);
}
return $canvases;
Expand Down Expand Up @@ -1303,10 +1300,9 @@ $.fn.removeLayerFromGroup = function removeLayerFromGroup(layerId, groupName) {

// Get topmost layer that intersects with event coordinates
function _getIntersectingLayer(data: JCanvasInternalData) {
let layer: JCanvasLayer | null, mask: JCanvasObject, m;

// Store the topmost layer
layer = null;
let layer: JCanvasLayer | null = null;
let mask: JCanvasObject;

// Get the topmost layer whose visible area intersects event coordinates
for (let i = data.intersecting.length - 1; i >= 0; i -= 1) {
Expand All @@ -1317,7 +1313,7 @@ function _getIntersectingLayer(data: JCanvasInternalData) {
if (layer._masks) {
// Search previous masks to ensure
// layer is visible at event coordinates
for (m = layer._masks.length - 1; m >= 0; m -= 1) {
for (let m = layer._masks.length - 1; m >= 0; m -= 1) {
mask = layer._masks[m];
// If mask does not intersect event coordinates
if (!mask.intersects) {
Expand Down Expand Up @@ -1608,10 +1604,7 @@ $.fn.drawLayers = function drawLayers(args) {
let isImageLayer: boolean = false;

// The layer index from which to start redrawing the canvas
let index = params.index;
if (!index) {
index = 0;
}
const index = params.index || 0;

for (let e = 0; e < $canvases.length; e += 1) {
const canvas = $canvases[e];
Expand Down

0 comments on commit 1eb10c5

Please sign in to comment.