1- import TC
2- from '../../js/transformationNew/TransformationController .js' ;
1+ import CT
2+ from './CardTransformable .js' ;
33import TF
4- from '../../js/transformation /TransformationFunctions.js' ;
4+ from '../../js/transformationNew /TransformationFunctions.js' ;
55import LA
66 from '../../js/math/LinearAlgebra.js' ;
77
@@ -11,19 +11,27 @@ import LA
1111 * @abstract
1212 * @extends TransformationController
1313 */
14- export default class cardAbstract extends TC {
14+ export default class cardAbstract {
1515 /**
1616 * @param {String } [modifier = ''] Modifier of the card block.
1717 * Default '' means mo modifier.
18+ * @param {function } postTransformFunction for examples, see
19+ * {js/transformation/TransformableElement/
20+ * PostTransformFunctions.js}
1821 * @returns {void }
1922 */
20- constructor ( modifier = '' ) {
21- super (
22- document . body ,
23- `.card${ modifier } > .card__inner`
24- ) ;
23+ constructor (
24+ modifier = '' ,
25+ postTransformFunction ,
26+ transformationFunction = cardAbstract . _transformationFunction ) {
27+
28+ this . _throwIfAbstractClass ( ) ;
2529
26- console . log ( this ) ;
30+ this . _ct = new CT (
31+ modifier ,
32+ postTransformFunction ,
33+ transformationFunction
34+ ) ;
2735 }
2836
2937 /**
@@ -38,7 +46,7 @@ export default class cardAbstract extends TC {
3846 * @returns {string } transformation with adjusted scale and 3d
3947 * rotation
4048 */
41- _transformationFunction ( args ) {
49+ static _transformationFunction ( args ) {
4250 const
4351 rotAxis = LA . vector ( args . transformOrigin , args . mousePosition ) ,
4452 rotation =
@@ -69,38 +77,15 @@ export default class cardAbstract extends TC {
6977 } ;
7078 }
7179
72- /**
73- * in any implementation, override this function with a function that
74- * does what should happen after transforming the element (eg.
75- * setting the correct background to the parent element)
76- * @see {PostTransformFunctions}
77- * @abstract
78- * @protected
79- * @param {event } event - event that caused the transformation
80- * @param {TransformableElement } element - element that was
81- * transformed
82- * @returns {void }
83- */
84- _postTransformFunction ( event , element ) {
85- //look for implementation examples in
86- // 'js/transformation/TransformableElement/
87- // PostTransformFunctions.js'
88- this . _throwIfAbstractFunction ( ) ;
89- }
90-
9180 /**
9281 * more specific version of {TransformationController}'s
9382 * mousemoveEventTransform that already specifies where to find the
9483 * passed transformation functions and what elements it applies to
9584 * @see TransformationController
9685 * @returns {void }
9786 */
98- mousemoveEventTransform ( ) {
99- super . mousemoveEventTransform (
100- this . _transformationFunction ,
101- '*' ,
102- this . _postTransformFunction
103- ) ;
87+ mousemoveEvent ( ) {
88+ this . _ct . mousemoveEventTransform ( ) ;
10489 }
10590
10691 /**
@@ -114,24 +99,4 @@ export default class cardAbstract extends TC {
11499 throw new Error ( 'cannot call functions in abstract class' ) ;
115100 }
116101 }
117-
118- /**
119- * Helper function that always throws an error. Override the method
120- * which calls this to avoid that.
121- * @private
122- * @throws {Error } 'cannot call functions in abstract class' if class
123- * name ends on 'Abstract'
124- * @throws {Error } 'cannot call function in child class of abstract
125- * class that does not override the abstract function' in any other
126- * case
127- * @returns {void }
128- */
129- _throwIfAbstractFunction ( ) {
130- this . _throwIfAbstractClass ( ) ;
131-
132- throw new Error (
133- 'cannot call function in child class of abstract class that ' +
134- 'does not override the abstract function'
135- ) ;
136- }
137102}
0 commit comments