1+ import MC from '../../js/mouseShadow/MouseShadowController.js' ;
2+
3+ /**
4+ * Base for the mouse shadow controller for button blocks, which automates
5+ * the mouse shadow effect
6+ * @abstract
7+ * @extends MouseShadowController
8+ */
9+ class Page extends MC {
10+ /**
11+ * @param {String } [modifier = ''] Modifier of the button block.
12+ * Default '' means mo modifier.
13+ * @returns {void }
14+ */
15+ constructor ( ) {
16+ super ( document . getElementsByTagName ( 'html' ) [ 0 ] , [ 'page' ] , '.page' ) ;
17+ }
18+
19+ /**
20+ * more specific version of {MouseShadowController}'s
21+ * mousemoveEventShadow that already specifies where to find the
22+ * passed shadow functions and what elements it applies to
23+ * @see MouseShadowController
24+ * @returns {void }
25+ */
26+ mousemoveEventShadow ( ) {
27+ super . mousemoveEventShadow (
28+ this . _shadowFunction ,
29+ '*' ,
30+ this . _postShadowFunction
31+ ) ;
32+ }
33+
34+ /**
35+ * function which takes an object args which contains e mousemove
36+ * event (event) and returns css changes
37+ * @param {object } args
38+ * @returns {object } object of css properties and their values
39+ */
40+ _shadowFunction ( args ) {
41+ const
42+ rect = args . eventControlElement . domElement . getBoundingClientRect ( ) ,
43+ hover = [
44+ args . event . clientX - rect . left ,
45+ args . event . clientY - rect . top
46+ ] ;
47+
48+ return {
49+ '--page--mouse-shadow-left' : hover [ 0 ] ,
50+ '--page--mouse-shadow-top' : hover [ 1 ] ,
51+ '--page--center' : Math . max (
52+ Math . abs ( args . event . clientX - 0.5 * rect . width ) ,
53+ Math . abs ( args . event . clientY - 0.5 * rect . height ) ) ,
54+ '--page--center-v' : Math . abs ( args . event . clientY - 0.5 * rect . height )
55+ } ;
56+ }
57+
58+ _postShadowFunction ( ) {
59+
60+ }
61+ }
62+
63+ new Page ( ) . mousemoveEventShadow ( ) ;
0 commit comments