@advanced-rest-client/arc-scroll-target-mixin
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "@advanced-rest-client/arc-scroll-target-mixin", | ||
"description": "arc-scroll-target-mixin is a port of iron-scroll-target-behavior that works with LitElement", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "Apache-2.0", | ||
@@ -33,16 +33,16 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@advanced-rest-client/arc-demo-helper": "^2.2.6", | ||
"@open-wc/eslint-config": "^4.2.0", | ||
"@open-wc/testing": "^2.5.32", | ||
"@web/dev-server": "^0.1.8", | ||
"@web/test-runner": "^0.12.16", | ||
"@web/test-runner-playwright": "^0.8.4", | ||
"eslint": "^7.21.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"husky": "^4.3.8", | ||
"lint-staged": "^10.5.4", | ||
"lit-element": "^2.4.0", | ||
"lit-html": "^1.3.0", | ||
"sinon": "^9.2.4", | ||
"typescript": "^4.2.3", | ||
"@advanced-rest-client/arc-demo-helper": "^3.0.2", | ||
"@open-wc/eslint-config": "^4.3.0", | ||
"@open-wc/testing": "^2.5.33", | ||
"@web/dev-server": "^0.1.22", | ||
"@web/test-runner": "^0.13.17", | ||
"@web/test-runner-playwright": "^0.8.8", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"husky": "^7.0.2", | ||
"lint-staged": "^11.1.2", | ||
"lit-element": "^2.5.1", | ||
"lit-html": "^1.4.1", | ||
"sinon": "^11.1.2", | ||
"typescript": "^4.4.3", | ||
"typescript-lit-html-plugin": "^0.9.0" | ||
@@ -49,0 +49,0 @@ }, |
@@ -53,7 +53,9 @@ /* eslint-disable no-param-reassign */ | ||
} | ||
/** @returns {HTMLElement} */ | ||
get scrollTarget() { | ||
return this._scrollTarget; | ||
} | ||
/** @param {HTMLElement} value */ | ||
set scrollTarget(value) { | ||
@@ -225,3 +227,3 @@ if (value === this._scrollTarget) { | ||
} | ||
this.scrollTarget = target; | ||
this.scrollTarget = /** @type HTMLElement */ (target); | ||
} else if (this._isValidScrollTarget()) { | ||
@@ -237,3 +239,3 @@ this._oldScrollTarget = scrollTarget; | ||
* @method scroll | ||
* @param {number|!{left: number, top: number}} leftOrOptions The left position or scroll options | ||
* @param {number|ScrollToOptions} leftOrOptions The left position or scroll options | ||
* @param {number=} top The top position | ||
@@ -244,2 +246,3 @@ * @return {void} | ||
let left; | ||
let behavior; | ||
@@ -249,2 +252,3 @@ if (typeof leftOrOptions === 'object') { | ||
top = leftOrOptions.top; | ||
behavior = leftOrOptions.behavior; | ||
} else { | ||
@@ -257,6 +261,22 @@ left = leftOrOptions; | ||
if (this.scrollTarget === this._doc) { | ||
window.scrollTo(left, top); | ||
if (behavior) { | ||
window.scroll({ | ||
left, | ||
top, | ||
behavior, | ||
}); | ||
} else { | ||
window.scrollTo(left, top); | ||
} | ||
} else if (this._isValidScrollTarget()) { | ||
this.scrollTarget.scrollLeft = left; | ||
this.scrollTarget.scrollTop = top; | ||
if (behavior) { | ||
this.scrollTarget.scroll({ | ||
left, | ||
top, | ||
behavior, | ||
}); | ||
} else { | ||
this.scrollTarget.scrollLeft = left; | ||
this.scrollTarget.scrollTop = top; | ||
} | ||
} | ||
@@ -272,4 +292,3 @@ } | ||
if (this._isValidScrollTarget()) { | ||
return this.scrollTarget === this._doc ? window.innerWidth : | ||
this.scrollTarget.offsetWidth; | ||
return this.scrollTarget === this._doc ? window.innerWidth : this.scrollTarget.offsetWidth; | ||
} | ||
@@ -276,0 +295,0 @@ return 0; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19306
462