Skip to content

Commit

Permalink
Turn this into experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
nainar committed Aug 2, 2018
1 parent 08af034 commit 193f4b1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
1 change: 1 addition & 0 deletions build-system/global-configs/canary-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"amp-live-list-sorting": 1,
"amp-sidebar toolbar": 1,
"svg-in-mustache": 1,
"amp-carousel-scroll-snap": 1,
"amp-consent": 1,
"amp-img-native-srcset": 1,
"amp-story-v1": 1,
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-carousel/0.1/amp-carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ amp-carousel .amp-carousel-button.amp-disabled {
height: 100% !important;
justify-content: center !important;
position: relative !important;
scroll-snap-align: center !important;
scroll-snap-align: start !important;
width: 100% !important;
}

Expand All @@ -152,7 +152,7 @@ amp-carousel .amp-carousel-button.amp-disabled {
flex: 0 0 1px !important;
height: 100% !important;
position: relative !important;
scroll-snap-align: center !important;
scroll-snap-align: start !important;
width: 1px !important;
}

Expand Down
5 changes: 2 additions & 3 deletions extensions/amp-carousel/0.1/slidescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import {createCustomEvent} from '../../../src/event-helper';
import {dev} from '../../../src/log';
import {dict} from '../../../src/utils/object';
import {getStyle, setStyle} from '../../../src/style';
import {isExperimentOn} from '../../../src/experiments';
import {isFiniteNumber} from '../../../src/types';
import {isLayoutSizeDefined} from '../../../src/layout';
import {numeric} from '../../../src/transition';
import {startsWith} from '../../../src/string';
import {triggerAnalyticsEvent} from '../../../src/analytics';

/** @const {string} */
Expand Down Expand Up @@ -123,8 +123,7 @@ export class AmpSlideScroll extends BaseSlides {
this.action_ = null;

/** @private {boolean} */
this.shouldDisableCssSnap_ = startsWith(
Services.platformFor(this.win).getIosVersionString(), '10.3');
this.shouldDisableCssSnap_ = isExperimentOn(this.win, 'amp-carousel-scroll-snap');
}

/** @override */
Expand Down
16 changes: 0 additions & 16 deletions extensions/amp-carousel/0.1/test/test-slidescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,6 @@ describes.realWin('SlideScroll', {
});
});

it('should create start/end markers when scroll-snap is available', () => {
return getAmpSlideScroll().then(ampSlideScroll => {
const impl = ampSlideScroll.implementation_;
ampSlideScroll.style['scrollSnapType'] = '';
ampSlideScroll.style['webkitScrollSnapType'] = '';
ampSlideScroll.style['msScrollSnapType'] = '';
impl.buildCarousel();
expect(
ampSlideScroll.getElementsByClassName(
'i-amphtml-carousel-start-marker').length).to.be.at.least(1);
expect(
ampSlideScroll.getElementsByClassName(
'i-amphtml-carousel-end-marker').length).to.be.at.least(1);
});
});

it('should go to the correct slide on button click', () => {
return getAmpSlideScroll().then(ampSlideScroll => {
const impl = ampSlideScroll.implementation_;
Expand Down
6 changes: 6 additions & 0 deletions tools/experiments/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ const EXPERIMENTS = [
spec: 'https://github.com/ampproject/amphtml/pull/17229',
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/17230',
},
{
id: 'amp-carousel-scroll-snap',
name: 'Enables scroll snap on carousel across all browsers/OSes',
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/16508',
},

];

if (getMode().localDev) {
Expand Down

0 comments on commit 193f4b1

Please sign in to comment.