I've used the flashlight effect from My Father's Long Long legs on certain passages in my Twine (using Sugarcube 2.21.0) and it works well but as mentioned on the other Twine forum here, this keeps the cursor effect on throughout the Twine (meaning my background images move around as well outside the passages in which this effect is needed). As one of the people on the forum link above says:
warning: Both of the above Harlowe and SC2 passage tag based solutions suffer from the same issue, that being that the Javascript used to track the mouse cursor movement is active even when the flashlight effect is not being displayed.
A better solution would include the usage of a jQuery .off("mousemove") to disable the mouse cursor tracking when not needed, and only attach the mousemove tracking when required.
I have absolutely no knowledge of Jquery so I have no idea how to do this.
This is my script (I have of course CSS to style the effect):
$("body").mousemove(function(e){
$("body").css('background-position',(e.pageX - 250)+'px '+(e.pageY - 250)+'px');
});
Would anyone be able to help me out here? Alternatively, is there any way to apply Javascript only to certain passages, the way CSS can be? Any help would be much appreciated!