Skip to content

Commit

Permalink
Merge pull request #9 from conterra/fix-time-extent-restoring
Browse files Browse the repository at this point in the history
Reset the time slider's time extent when it is reopened
  • Loading branch information
sholtkamp authored Aug 13, 2024
2 parents 41171cb + b69ab31 commit e1cbfb9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ export default class TimeSliderWidgetController {

public onToolActivated(): void {
this.getView().then((view: __esri.View) => {
// Whenever the TimeSlider is opened, we want to (re)set it to the configured time extent.
this.timeSliderWidget.timeExtent = this.getTimeExtentFromConfig(this._properties, "timeExtent");

view.timeExtent = this.timeSliderWidget.timeExtent;
this.changeAllLayerTimeExtents(view.timeExtent);
if (this._properties.playOnStartup) {
this.timeSliderWidget.play();
}
this.timeExtentWatcher = this.timeSliderWidget.watch("timeExtent", (value: __esri.TimeExtent) => {
view.timeExtent = value;
this.changeAllLayerTimeExtents(value);
});
});
Expand Down
22 changes: 1 addition & 21 deletions src/main/js/bundles/dn_timeslider/TimeSliderWidgetFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,19 @@

import { InjectedReference } from "apprt-core/InjectedReference";
import EsriDijit from "esri-widgets/EsriDijit";
import Binding, { Bindable, Binding as BindingType } from 'apprt-binding/Binding';

import { MapWidgetModel } from "map-widget/api";
import type TimeSliderWidgetController from "./TimeSliderWidgetController";

export default class TimeSliderWidgetFactory {

private binding: BindingType;
private _mapWidgetModel: InjectedReference<MapWidgetModel>;
private _timeSliderWidgetController: TimeSliderWidgetController;

public deactivate(): void {
this.deactivateBinding();
}
private _timeSliderWidgetController: InjectedReference<TimeSliderWidgetController>;

public createInstance(): any {
return this.getWidget();
}

private getWidget(): any {
const timeSliderWidget = this._timeSliderWidgetController.getWidget();
const mapWidgetModel = this._mapWidgetModel;

this.binding = Binding.for(timeSliderWidget as Bindable, mapWidgetModel)
.syncToLeft("view")
.enable()
.syncToLeftNow();

return new (EsriDijit as any)(timeSliderWidget);
}

private deactivateBinding(): void {
this.binding.unbind();
this.binding = undefined;
}
}
7 changes: 1 addition & 6 deletions src/main/js/bundles/dn_timeslider/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"dependencies": {
"esri": "^4.20.0",
"esri-widgets": "^4.12.0",
"map-widget": "^4.12.0",
"apprt-binding": "^4.12.0"
"map-widget": "^4.12.0"
},
"CSS-Themes-Extension": [
{
Expand Down Expand Up @@ -152,10 +151,6 @@
"widgetRole": "timeSliderWidget"
},
"references": [
{
"name": "_mapWidgetModel",
"providing": "map-widget.MapWidgetModel"
},
{
"name": "_timeSliderWidgetController",
"providing": "dn_timeslider.TimeSliderWidgetController"
Expand Down

0 comments on commit e1cbfb9

Please sign in to comment.