Skip to content

Commit

Permalink
Merge pull request #286 from renbaoshuo/scroll-snap
Browse files Browse the repository at this point in the history
feat: add `scroll-snap` prefix support
  • Loading branch information
thysultan committed Mar 19, 2022
2 parents fbda346 + c60d3ca commit 66582ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Prefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export function prefix (value, length) {
}

return WEBKIT + value + MS + value + value
// scroll-snap-type
case 2903:
return WEBKIT + value + MS + value + value
// scroll-margin, scroll-margin-(top|right|bottom|left)
case 5719: case 2647: case 2135: case 3927: case 2391:
return replace(value, 'scroll-', 'scroll-snap-') + value
}

return value
Expand Down
9 changes: 9 additions & 0 deletions test/Prefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,13 @@ describe('Prefixer', () => {
`animation-timing-function:cubic-bezier(0.1,0.7,1.0,0.1);`
].join(''))
})

test('scroll-snap', () => {
expect(prefix(`scroll-snap-type:none;`, 16)).to.equal([`-webkit-scroll-snap-type:none;`, `-ms-scroll-snap-type:none;`, `scroll-snap-type:none;`].join(''))
expect(prefix(`scroll-margin:0;`, 13)).to.equal([`scroll-snap-margin:0;`, `scroll-margin:0;`].join(''))
expect(prefix(`scroll-margin-top:0;`, 17)).to.equal([`scroll-snap-margin-top:0;`, `scroll-margin-top:0;`].join(''))
expect(prefix(`scroll-margin-right:0;`, 19)).to.equal([`scroll-snap-margin-right:0;`, `scroll-margin-right:0;`].join(''))
expect(prefix(`scroll-margin-bottom:0;`, 20)).to.equal([`scroll-snap-margin-bottom:0;`, `scroll-margin-bottom:0;`].join(''))
expect(prefix(`scroll-margin-left:0;`, 18)).to.equal([`scroll-snap-margin-left:0;`, `scroll-margin-left:0;`].join(''))
})
})

0 comments on commit 66582ef

Please sign in to comment.