@progress/kendo-angular-common 3.1.1 → 3.2.0-dev.202210041342
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { isDocumentAvailable } from "./is-document-available";
|
|
6
|
+
const canCreateElement = () => isDocumentAvailable() && document.createElement;
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export function getScrollbarWidth() {
|
|
11
|
+
let scrollbarWidth = 0;
|
|
12
|
+
if (canCreateElement()) {
|
|
13
|
+
const div = document.createElement('div');
|
|
14
|
+
div.style.cssText = 'overflow:scroll;overflow-x:hidden;zoom:1;clear:both;display:block';
|
|
15
|
+
div.innerHTML = ' ';
|
|
16
|
+
document.body.appendChild(div);
|
|
17
|
+
scrollbarWidth = div.offsetWidth - div.scrollWidth;
|
|
18
|
+
document.body.removeChild(div);
|
|
19
|
+
}
|
|
20
|
+
return scrollbarWidth;
|
|
21
|
+
}
|
|
@@ -3,22 +3,10 @@
|
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { Injectable, EventEmitter } from '@angular/core';
|
|
6
|
+
import { getScrollbarWidth } from './get-scrollbar-width';
|
|
6
7
|
import { isDocumentAvailable } from './is-document-available';
|
|
7
8
|
import * as i0 from "@angular/core";
|
|
8
|
-
const canCreateElement = () => isDocumentAvailable() && document.createElement;
|
|
9
9
|
const propName = '--kendo-scrollbar-width';
|
|
10
|
-
function scrollbarWidth() {
|
|
11
|
-
let scrollbarWidth = 0;
|
|
12
|
-
if (canCreateElement()) {
|
|
13
|
-
const div = document.createElement('div');
|
|
14
|
-
div.style.cssText = 'overflow:scroll;overflow-x:hidden;zoom:1;clear:both;display:block';
|
|
15
|
-
div.innerHTML = ' ';
|
|
16
|
-
document.body.appendChild(div);
|
|
17
|
-
scrollbarWidth = div.offsetWidth - div.scrollWidth;
|
|
18
|
-
document.body.removeChild(div);
|
|
19
|
-
}
|
|
20
|
-
return scrollbarWidth;
|
|
21
|
-
}
|
|
22
10
|
/**
|
|
23
11
|
* @hidden
|
|
24
12
|
*/
|
|
@@ -26,7 +14,7 @@ export class ScrollbarWidthService {
|
|
|
26
14
|
constructor() {
|
|
27
15
|
this.changes = new EventEmitter();
|
|
28
16
|
if (typeof window !== 'undefined' && isDocumentAvailable()) {
|
|
29
|
-
document.body.style.setProperty(propName, `${
|
|
17
|
+
document.body.style.setProperty(propName, `${getScrollbarWidth()}px`);
|
|
30
18
|
}
|
|
31
19
|
}
|
|
32
20
|
}
|
|
@@ -702,8 +702,10 @@ class PreventableEvent {
|
|
|
702
702
|
}
|
|
703
703
|
|
|
704
704
|
const canCreateElement = () => isDocumentAvailable() && document.createElement;
|
|
705
|
-
|
|
706
|
-
|
|
705
|
+
/**
|
|
706
|
+
* @hidden
|
|
707
|
+
*/
|
|
708
|
+
function getScrollbarWidth() {
|
|
707
709
|
let scrollbarWidth = 0;
|
|
708
710
|
if (canCreateElement()) {
|
|
709
711
|
const div = document.createElement('div');
|
|
@@ -715,6 +717,8 @@ function scrollbarWidth() {
|
|
|
715
717
|
}
|
|
716
718
|
return scrollbarWidth;
|
|
717
719
|
}
|
|
720
|
+
|
|
721
|
+
const propName = '--kendo-scrollbar-width';
|
|
718
722
|
/**
|
|
719
723
|
* @hidden
|
|
720
724
|
*/
|
|
@@ -722,7 +726,7 @@ class ScrollbarWidthService {
|
|
|
722
726
|
constructor() {
|
|
723
727
|
this.changes = new EventEmitter();
|
|
724
728
|
if (typeof window !== 'undefined' && isDocumentAvailable()) {
|
|
725
|
-
document.body.style.setProperty(propName, `${
|
|
729
|
+
document.body.style.setProperty(propName, `${getScrollbarWidth()}px`);
|
|
726
730
|
}
|
|
727
731
|
}
|
|
728
732
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export declare function getScrollbarWidth(): number;
|