refactor(sticky): shorten wxs code (#3899)

This commit is contained in:
rex 2020-12-22 20:58:58 +08:00 committed by GitHub
parent 5626547a19
commit ed0626fa89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,19 +1,20 @@
/* eslint-disable */
var style = require('../wxs/style.wxs');
var addUnit = require('../wxs/add-unit.wxs');
function wrapStyle(data) {
return style({
transform: data.transform
? 'translate3d(0, ' + data.transform + 'px, 0)'
: '',
top: data.fixed ? data.offsetTop + 'px' : '',
top: data.fixed ? addUnit(data.offsetTop) : '',
'z-index': data.zIndex,
});
}
function containerStyle(data) {
return style({
height: data.fixed ? data.height + 'px' : '',
height: data.fixed ? addUnit(data.height) : '',
'z-index': data.zIndex,
});
}