From a48be746f3bcfce57761f88cc009b5df802ed8cd Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 20 Oct 2019 00:00:11 +0200 Subject: Support manual mode in Pace module. --- .../main/kotlin/pl/treksoft/kvision/pace/Pace.kt | 95 +++++++++++++--------- 1 file changed, 56 insertions(+), 39 deletions(-) (limited to 'kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt index 77ae00cf..8905ce2c 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt @@ -92,47 +92,56 @@ class PaceOptions( restartOnPushState: Boolean? = null, restartOnRequestAfter: Double? = null, startOnPageLoad: Boolean? = null, - target: String? = null + target: String? = null, + manual: Boolean = false ) { internal var paceOptionsJs: dynamic = obj { - if (ajax != null) { - this.ajax = ajax.paceAjaxOptionsJs - } - if (catchupTime != null) { - this.catchupTime = catchupTime - } - if (easeFactor != null) { - this.easeFactor = easeFactor - } - if (elements != null) { - this.elements = elements.paceElementsOptionsJs - } - if (eventLag != null) { - this.eventLag = eventLag.paceEventLagOptionsJs - } - if (ghostTime != null) { - this.ghostTime = ghostTime - } - if (initialRate != null) { - this.initialRate = initialRate - } - if (maxProgressPerFrame != null) { - this.maxProgressPerFrame = maxProgressPerFrame - } - if (minTime != null) { - this.minTime = minTime - } - if (restartOnPushState != null) { - this.restartOnPushState = restartOnPushState - } - if (restartOnRequestAfter != null) { - this.restartOnRequestAfter = restartOnRequestAfter - } - if (startOnPageLoad != null) { - this.startOnPageLoad = startOnPageLoad - } - if (target != null) { - this.target = target + if (!manual) { + if (ajax != null) { + this.ajax = ajax.paceAjaxOptionsJs + } + if (catchupTime != null) { + this.catchupTime = catchupTime + } + if (easeFactor != null) { + this.easeFactor = easeFactor + } + if (elements != null) { + this.elements = elements.paceElementsOptionsJs + } + if (eventLag != null) { + this.eventLag = eventLag.paceEventLagOptionsJs + } + if (ghostTime != null) { + this.ghostTime = ghostTime + } + if (initialRate != null) { + this.initialRate = initialRate + } + if (maxProgressPerFrame != null) { + this.maxProgressPerFrame = maxProgressPerFrame + } + if (minTime != null) { + this.minTime = minTime + } + if (restartOnPushState != null) { + this.restartOnPushState = restartOnPushState + } + if (restartOnRequestAfter != null) { + this.restartOnRequestAfter = restartOnRequestAfter + } + if (startOnPageLoad != null) { + this.startOnPageLoad = startOnPageLoad + } + if (target != null) { + this.target = target + } + } else { + this.ajax = false + this.elements = false + this.document = false + this.eventLag = false + this.startOnPageLoad = false } } } @@ -157,5 +166,13 @@ class Pace { fun stop() { window["Pace"].stop() } + + fun show() { + window["Pace"].bar.render() + } + + fun hide() { + window["Pace"].stop() + } } } -- cgit