@@ -19,14 +19,18 @@ import { faForward, faPlay, faStop } from '@fortawesome/free-solid-svg-icons';
1919import { AdvancedOptionsComponent , Appearance , SettingsHolder , Timing }
2020 from '../advanced-options/advanced-options.component' ;
2121import {
22- adjustForEclipticWheel , AngleTriplet , BasicPositions , calculateBasicPositions , calculateMechanicalPositions , MILLIS_PER_DAY ,
23- solarSystem , ZeroAngles
22+ adjustForEclipticWheel , AngleTriplet , BasicPositions , calculateBasicPositions , calculateMechanicalPositions ,
23+ MILLIS_PER_DAY , MILLIS_PER_SIDEREAL_DAY , solarSystem , ZeroAngles
2424} from 'src/math/math' ;
2525import { adjustGraphicsForLatitude , initSvgHost , sunlitMoonPath , SvgHost } from 'src/svg/svg' ;
2626import { sizeChanges } from '../main' ;
27+ import { Subscription , timer } from 'rxjs' ;
2728
2829const { DATE , DATETIME_LOCAL , julianDay, TIME } = ttime ;
2930
31+ const CLICK_REPEAT_DELAY = 500 ;
32+ const CLICK_REPEAT_RATE = 100 ;
33+
3034const RESUME_FILTERING_DELAY = 1000 ;
3135const SIMPLE_FILTER_IS_SLOW_TOO = isAndroid ( ) || ( isSafari ( ) && isMacOS ( ) ) ;
3236const STOP_FILTERING_DELAY = SIMPLE_FILTER_IS_SLOW_TOO ? 1000 : 3000 ;
@@ -44,6 +48,7 @@ const pragueLon = 14.4185;
4448
4549const defaultSettings = {
4650 additionalPlanets : false ,
51+ animateBySiderealDays : false ,
4752 appearance : Appearance . CURRENT ,
4853 background : '#4D4D4D' ,
4954 collapsed : false ,
@@ -161,7 +166,9 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
161166 private _background = '#4D4D4D' ;
162167 private _collapsed = false ;
163168 private delayedCollapse = false ;
169+ private eventClickTimer : Subscription ;
164170 private eventFinder = new EventFinder ( ) ;
171+ private eventGoBack = false ;
165172 private eventType = EventType . EQUISOLSTICE ;
166173 private globe : Globe
167174 private graphicsChangeLastTime = - 1 ;
@@ -222,6 +229,7 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
222229 self : AppComponent & SvgHost = this ;
223230
224231 altFour = false ;
232+ animateBySiderealDays = false ;
225233 bohemianTime = '' ;
226234 canEditName = false ;
227235 canSaveName = false ;
@@ -615,7 +623,13 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
615623 }
616624
617625 stop ( ) : void {
618- this . playing = false ;
626+ if ( this . playing ) {
627+ this . playing = false ;
628+
629+ // Round time to the nearest whole minute when animation stops.
630+ if ( this . playSpeed === PlaySpeed . FAST )
631+ this . time = floor ( ( this . time + 30000 ) / 60000 ) * 60000 ;
632+ }
619633 }
620634
621635 private playStep = ( ) : void => {
@@ -627,7 +641,8 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
627641 if ( this . playSpeed === PlaySpeed . NORMAL )
628642 this . time = this . playTimeBase + floor ( elapsed / 25 ) * 60_000 ;
629643 else
630- this . time = this . playTimeBase + floor ( elapsed / 100 ) * MILLIS_PER_DAY ;
644+ this . time = this . playTimeBase + floor ( elapsed / 100 ) *
645+ ( this . animateBySiderealDays ? MILLIS_PER_SIDEREAL_DAY : MILLIS_PER_DAY ) ;
631646
632647 if ( this . lastWallTime && this . lastWallTime . y === this . MAX_YEAR &&
633648 this . lastWallTime . m === 12 && this . lastWallTime . d === 31 )
@@ -1079,8 +1094,42 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
10791094 this . canSaveName = false ;
10801095 }
10811096
1082- skipToEvent ( previous = false ) : void {
1097+ eventClick ( evt ?: TouchEvent | MouseEvent , goBack = false ) : void {
1098+ if ( ! evt )
1099+ this . stopEventClickTimer ( ) ;
1100+ else if ( evt ?. type === 'touchstart' || evt ?. type === 'mousedown' ) {
1101+ if ( evt . type === 'touchstart' && evt . cancelable )
1102+ evt . preventDefault ( ) ;
1103+
1104+ this . eventGoBack = goBack ;
1105+
1106+ if ( ! this . eventClickTimer ) {
1107+ this . eventClickTimer = timer ( CLICK_REPEAT_DELAY , CLICK_REPEAT_RATE ) . subscribe ( ( ) => {
1108+ this . skipToEvent ( this . eventGoBack ) ;
1109+ } ) ;
1110+ }
1111+ }
1112+ else if ( evt ?. type === 'touchend' || evt ?. type === 'mouseup' ) {
1113+ if ( evt . type === 'touchend' && evt . cancelable )
1114+ evt . preventDefault ( ) ;
1115+
1116+ if ( this . eventClickTimer ) {
1117+ this . stopEventClickTimer ( ) ;
1118+ this . skipToEvent ( this . eventGoBack ) ;
1119+ }
1120+ }
1121+ }
1122+
1123+ private stopEventClickTimer ( ) : void {
1124+ if ( this . eventClickTimer ) {
1125+ this . eventClickTimer . unsubscribe ( ) ;
1126+ this . eventClickTimer = undefined ;
1127+ }
1128+ }
1129+
1130+ private skipToEvent ( previous : boolean ) : void {
10831131 if ( this . trackTime ) {
1132+ this . stopEventClickTimer ( ) ;
10841133 this . confirmService . confirm ( {
10851134 message : $localize `Turn off "Track current time" and change the clock time?` ,
10861135 accept : ( ) => {
@@ -1122,12 +1171,14 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
11221171 const eventText = AppComponent . translateEvent ( evt . eventText ) ;
11231172 const year = new DateTime ( evt . eventTime . utcMillis , this . zone ) . wallTime . year ;
11241173
1174+ this . messageService . clear ( ) ;
1175+
11251176 if ( year < this . MIN_YEAR || year > this . MAX_YEAR )
11261177 this . messageService . add ( { severity : 'error' , summary : $localize `Event` ,
11271178 detail : $localize `Event outside of ${ this . MIN_YEAR } -${ this . MAX_YEAR } year range.` } ) ;
11281179 else {
11291180 this . time = evt . eventTime . utcMillis ;
1130- this . messageService . add ( { severity : 'info' , summary : $localize `Event` , detail : eventText , life : 1000 } ) ;
1181+ this . messageService . add ( { severity : 'info' , summary : $localize `Event` , detail : eventText } ) ;
11311182 }
11321183 }
11331184 }
0 commit comments