1- /*import TransformationController
2- from '../../js/transformation/TransformationController.js';
3- import TF
4- from '../../js/transformation/TransformationFunctions.js';
5- import LA from '../../js/math/LinearAlgebra.js';*/
6-
71export default ( ) => {
82 //mousemoveTransformations();
9- startScrollPositionUpdater ( ) ;
3+ startPositionUpdater ( ) ;
104} ;
115
126/**
137 * @todo i don't know what is happening here. Check it and update
148 * documentation. The whole file is a big mess.
159 * @returns {void }
1610 */
17- function startScrollPositionUpdater ( ) {
11+ function startPositionUpdater ( ) {
1812 document . querySelector ( '.projects__inner' )
1913 . addEventListener ( "scroll" , onScroll ) ;
2014
2115 document . querySelector ( '.projects' )
2216 . addEventListener ( "scroll" , onScroll ) ;
17+
18+ window
19+ . addEventListener ( 'devicemotion' , onOrientationChange , true ) ;
2320}
2421
2522/**
@@ -32,58 +29,17 @@ function onScroll(e) {
3229 document . querySelector ( '.projects' ) . style
3330 . setProperty ( '--projects--scroll-top' , e . target . scrollTop + 'px' ) ;
3431}
35- /*
36- function mousemoveTransformations() {
37- const tc = new TransformationController(
38- document.querySelector('.projects__inner')
39- );
40-
41- tc.mousemoveEventTransform(
42- combined3dRot,
43- '.project-card__inner',
44- setParentBackground
45- );
46- }
4732
48- function combined3dRot(absoluteOrigin, mousePosition ) {
49- const rotAxis = LA.vector(absoluteOrigin, mousePosition),
50- rotation = TF.advBellCurve(
51- absoluteOrigin, mousePosition, 0, 1, 2
52- ) - 1,
33+ function onOrientationChange ( e ) {
34+ const
35+ a = 1 * e . accelerationIncludingGravity . x ,
36+ b = 1 * e . accelerationIncludingGravity . y ,
37+ c = 1 * e . accelerationIncludingGravity . z ;
5338
54- invRotAxis = [
55- rotAxis[1],
56- -rotAxis[0]
57- ];
58-
59- return `perspective(2000px) ` +
60- `translateX(calc(0.5 * var(--h) - 0.5 * var(--w))) ` +
61- `translateY(calc(0.5 * var(--w) - 0.5 * var(--h))) ` +
62- `rotate(90deg) ` +
63- `rotate3d(${invRotAxis[0]}, ` +
64- `${invRotAxis[1]}, 0, ${rotation}rad) ` +
65- `scale(${TF
66- .advBellCurve(absoluteOrigin, mousePosition,
67- 0.9, 1, 2)}) ` +
68- 'translateZ(0) ';
69- }
70-
71- function setParentBackground(event, element) {
72- const parent = element.domElement.parentElement,
73- background = element.surroundingBackground(
74- 'var(--c0)',
75- [
76- parent.offsetWidth,
77- parent.offsetHeight
78- ],
79- 'transparent',
80- 5
81- );
82- parent.style.setProperty(
83- 'background',
84- background +
85- ', 0 var(--projects--scroll-top, 0) ' +
86- 'repeating-linear-gradient(45deg, var(--c1) 0px, ' +
87- 'var(--c0) 40px, var(--c1) 80px)');
39+ document . querySelector ( '.projects' ) . style
40+ . setProperty ( '--projects--orientation-a' , a ) ;
41+ document . querySelector ( '.projects' ) . style
42+ . setProperty ( '--projects--orientation-b' , - b ) ;
43+ document . querySelector ( '.projects' ) . style
44+ . setProperty ( '--projects--orientation-c' , c ) ;
8845}
89- */
0 commit comments