|
1 |
| -import { ChangeType, ContentView, Device, KeyedTemplate, Property, ProxyViewContainer, StackLayout, Utils, View, ViewBase } from '@nativescript/core'; |
| 1 | +import { |
| 2 | + ChangeType, |
| 3 | + ContentView, |
| 4 | + CoreTypes, |
| 5 | + Device, |
| 6 | + KeyedTemplate, |
| 7 | + Property, |
| 8 | + ProxyViewContainer, |
| 9 | + Utils, |
| 10 | + View, |
| 11 | + ViewBase, |
| 12 | + paddingBottomProperty, |
| 13 | + paddingLeftProperty, |
| 14 | + paddingRightProperty, |
| 15 | + paddingTopProperty |
| 16 | +} from '@nativescript/core'; |
2 | 17 | import { isString } from '@nativescript/core/utils/types';
|
3 | 18 | import {
|
4 | 19 | ItemEventData,
|
@@ -311,6 +326,47 @@ export class Pager extends PagerBase {
|
311 | 326 | this.setObservableArrayInstance(value);
|
312 | 327 | }
|
313 | 328 |
|
| 329 | + private _setPadding(newPadding: { top?: number; right?: number; bottom?: number; left?: number }) { |
| 330 | + const nativeView = this.nativeViewProtected; |
| 331 | + const padding = { |
| 332 | + top: nativeView.getPaddingTop(), |
| 333 | + right: nativeView.getPaddingRight(), |
| 334 | + bottom: nativeView.getPaddingBottom(), |
| 335 | + left: nativeView.getPaddingLeft() |
| 336 | + }; |
| 337 | + // tslint:disable-next-line:prefer-object-spread |
| 338 | + const newValue = Object.assign(padding, newPadding); |
| 339 | + nativeView.setClipToPadding(false); |
| 340 | + nativeView.setPadding(newValue.left, newValue.top, newValue.right, newValue.bottom); |
| 341 | + } |
| 342 | + [paddingTopProperty.getDefault](): CoreTypes.LengthType { |
| 343 | + return { value: this._defaultPaddingTop, unit: 'px' }; |
| 344 | + } |
| 345 | + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { |
| 346 | + this._setPadding({ top: this.effectivePaddingTop }); |
| 347 | + } |
| 348 | + |
| 349 | + [paddingRightProperty.getDefault](): CoreTypes.LengthType { |
| 350 | + return { value: this._defaultPaddingRight, unit: 'px' }; |
| 351 | + } |
| 352 | + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { |
| 353 | + this._setPadding({ right: this.effectivePaddingRight }); |
| 354 | + } |
| 355 | + |
| 356 | + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { |
| 357 | + return { value: this._defaultPaddingBottom, unit: 'px' }; |
| 358 | + } |
| 359 | + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { |
| 360 | + this._setPadding({ bottom: this.effectivePaddingBottom }); |
| 361 | + } |
| 362 | + |
| 363 | + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { |
| 364 | + return { value: this._defaultPaddingLeft, unit: 'px' }; |
| 365 | + } |
| 366 | + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { |
| 367 | + this._setPadding({ left: this.effectivePaddingLeft }); |
| 368 | + } |
| 369 | + |
314 | 370 | private _updateScrollPosition() {
|
315 | 371 | const index = this.circularMode ? this.selectedIndex + 1 : this.selectedIndex;
|
316 | 372 | const nativeView = this.nativeViewProtected;
|
|
0 commit comments