first
This commit is contained in:
1
node_modules/vant/es/notice-bar/index.css
generated
vendored
Normal file
1
node_modules/vant/es/notice-bar/index.css
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.van-notice-bar{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center;height:40px;padding:0 16px;color:#ed6a0c;font-size:14px;line-height:24px;background-color:#fffbe8}.van-notice-bar__left-icon,.van-notice-bar__right-icon{min-width:24px;font-size:16px}.van-notice-bar__right-icon{text-align:right;cursor:pointer}.van-notice-bar__wrap{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-flex:1;-webkit-flex:1;flex:1;-webkit-box-align:center;-webkit-align-items:center;align-items:center;height:100%;overflow:hidden}.van-notice-bar__content{position:absolute;white-space:nowrap;-webkit-transition-timing-function:linear;transition-timing-function:linear}.van-notice-bar__content.van-ellipsis{max-width:100%}.van-notice-bar--wrapable{height:auto;padding:8px 16px}.van-notice-bar--wrapable .van-notice-bar__wrap{height:auto}.van-notice-bar--wrapable .van-notice-bar__content{position:relative;white-space:normal;word-wrap:break-word}
|
223
node_modules/vant/es/notice-bar/index.js
generated
vendored
Normal file
223
node_modules/vant/es/notice-bar/index.js
generated
vendored
Normal file
@ -0,0 +1,223 @@
|
||||
import { createNamespace, isDef } from '../utils';
|
||||
import { doubleRaf, raf } from '../utils/dom/raf';
|
||||
import { BindEventMixin } from '../mixins/bind-event';
|
||||
import Icon from '../icon';
|
||||
|
||||
var _createNamespace = createNamespace('notice-bar'),
|
||||
createComponent = _createNamespace[0],
|
||||
bem = _createNamespace[1];
|
||||
|
||||
export default createComponent({
|
||||
mixins: [BindEventMixin(function (bind) {
|
||||
// fix cache issues with forwards and back history in safari
|
||||
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
|
||||
bind(window, 'pageshow', this.reset);
|
||||
})],
|
||||
inject: {
|
||||
vanPopup: {
|
||||
default: null
|
||||
}
|
||||
},
|
||||
props: {
|
||||
text: String,
|
||||
mode: String,
|
||||
color: String,
|
||||
leftIcon: String,
|
||||
wrapable: Boolean,
|
||||
background: String,
|
||||
scrollable: {
|
||||
type: Boolean,
|
||||
default: null
|
||||
},
|
||||
delay: {
|
||||
type: [Number, String],
|
||||
default: 1
|
||||
},
|
||||
speed: {
|
||||
type: [Number, String],
|
||||
default: 60
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
show: true,
|
||||
offset: 0,
|
||||
duration: 0,
|
||||
wrapWidth: 0,
|
||||
contentWidth: 0
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
scrollable: 'reset',
|
||||
text: {
|
||||
handler: 'reset',
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created: function created() {
|
||||
// https://github.com/vant-ui/vant/issues/8634
|
||||
if (this.vanPopup) {
|
||||
this.vanPopup.onReopen(this.reset);
|
||||
}
|
||||
},
|
||||
activated: function activated() {
|
||||
this.reset();
|
||||
},
|
||||
methods: {
|
||||
onClickIcon: function onClickIcon(event) {
|
||||
if (this.mode === 'closeable') {
|
||||
this.show = false;
|
||||
this.$emit('close', event);
|
||||
}
|
||||
},
|
||||
onTransitionEnd: function onTransitionEnd() {
|
||||
var _this = this;
|
||||
|
||||
this.offset = this.wrapWidth;
|
||||
this.duration = 0; // wait for Vue to render offset
|
||||
// using nextTick won't work in iOS14
|
||||
|
||||
raf(function () {
|
||||
// use double raf to ensure animation can start
|
||||
doubleRaf(function () {
|
||||
_this.offset = -_this.contentWidth;
|
||||
_this.duration = (_this.contentWidth + _this.wrapWidth) / _this.speed;
|
||||
|
||||
_this.$emit('replay');
|
||||
});
|
||||
});
|
||||
},
|
||||
// not an exposed-api, but may used by some users
|
||||
start: function start() {
|
||||
this.reset();
|
||||
},
|
||||
// @exposed-api
|
||||
reset: function reset() {
|
||||
var _this2 = this;
|
||||
|
||||
var delay = isDef(this.delay) ? this.delay * 1000 : 0;
|
||||
this.offset = 0;
|
||||
this.duration = 0;
|
||||
this.wrapWidth = 0;
|
||||
this.contentWidth = 0;
|
||||
clearTimeout(this.startTimer);
|
||||
this.startTimer = setTimeout(function () {
|
||||
var _this2$$refs = _this2.$refs,
|
||||
wrap = _this2$$refs.wrap,
|
||||
content = _this2$$refs.content;
|
||||
|
||||
if (!wrap || !content || _this2.scrollable === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapWidth = wrap.getBoundingClientRect().width;
|
||||
var contentWidth = content.getBoundingClientRect().width;
|
||||
|
||||
if (_this2.scrollable || contentWidth > wrapWidth) {
|
||||
doubleRaf(function () {
|
||||
_this2.offset = -contentWidth;
|
||||
_this2.duration = contentWidth / _this2.speed;
|
||||
_this2.wrapWidth = wrapWidth;
|
||||
_this2.contentWidth = contentWidth;
|
||||
});
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
},
|
||||
render: function render() {
|
||||
var _this3 = this;
|
||||
|
||||
var h = arguments[0];
|
||||
var slots = this.slots,
|
||||
mode = this.mode,
|
||||
leftIcon = this.leftIcon,
|
||||
onClickIcon = this.onClickIcon;
|
||||
var barStyle = {
|
||||
color: this.color,
|
||||
background: this.background
|
||||
};
|
||||
var contentStyle = {
|
||||
transform: this.offset ? "translateX(" + this.offset + "px)" : '',
|
||||
transitionDuration: this.duration + 's'
|
||||
};
|
||||
|
||||
function LeftIcon() {
|
||||
var slot = slots('left-icon');
|
||||
|
||||
if (slot) {
|
||||
return slot;
|
||||
}
|
||||
|
||||
if (leftIcon) {
|
||||
return h(Icon, {
|
||||
"class": bem('left-icon'),
|
||||
"attrs": {
|
||||
"name": leftIcon
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function RightIcon() {
|
||||
var slot = slots('right-icon');
|
||||
|
||||
if (slot) {
|
||||
return slot;
|
||||
}
|
||||
|
||||
var iconName;
|
||||
|
||||
if (mode === 'closeable') {
|
||||
iconName = 'cross';
|
||||
} else if (mode === 'link') {
|
||||
iconName = 'arrow';
|
||||
}
|
||||
|
||||
if (iconName) {
|
||||
return h(Icon, {
|
||||
"class": bem('right-icon'),
|
||||
"attrs": {
|
||||
"name": iconName
|
||||
},
|
||||
"on": {
|
||||
"click": onClickIcon
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return h("div", {
|
||||
"attrs": {
|
||||
"role": "alert"
|
||||
},
|
||||
"directives": [{
|
||||
name: "show",
|
||||
value: this.show
|
||||
}],
|
||||
"class": bem({
|
||||
wrapable: this.wrapable
|
||||
}),
|
||||
"style": barStyle,
|
||||
"on": {
|
||||
"click": function click(event) {
|
||||
_this3.$emit('click', event);
|
||||
}
|
||||
}
|
||||
}, [LeftIcon(), h("div", {
|
||||
"ref": "wrap",
|
||||
"class": bem('wrap'),
|
||||
"attrs": {
|
||||
"role": "marquee"
|
||||
}
|
||||
}, [h("div", {
|
||||
"ref": "content",
|
||||
"class": [bem('content'), {
|
||||
'van-ellipsis': this.scrollable === false && !this.wrapable
|
||||
}],
|
||||
"style": contentStyle,
|
||||
"on": {
|
||||
"transitionend": this.onTransitionEnd
|
||||
}
|
||||
}, [this.slots() || this.text])]), RightIcon()]);
|
||||
}
|
||||
});
|
60
node_modules/vant/es/notice-bar/index.less
generated
vendored
Normal file
60
node_modules/vant/es/notice-bar/index.less
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-notice-bar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: @notice-bar-height;
|
||||
padding: @notice-bar-padding;
|
||||
color: @notice-bar-text-color;
|
||||
font-size: @notice-bar-font-size;
|
||||
line-height: @notice-bar-line-height;
|
||||
background-color: @notice-bar-background-color;
|
||||
|
||||
&__left-icon,
|
||||
&__right-icon {
|
||||
min-width: @notice-bar-icon-min-width;
|
||||
font-size: @notice-bar-icon-size;
|
||||
}
|
||||
|
||||
&__right-icon {
|
||||
text-align: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&__wrap {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&__content {
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
transition-timing-function: linear;
|
||||
|
||||
&.van-ellipsis {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&--wrapable {
|
||||
height: auto;
|
||||
padding: @notice-bar-wrapable-padding;
|
||||
|
||||
.van-notice-bar {
|
||||
&__wrap {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
&__content {
|
||||
position: relative;
|
||||
white-space: normal;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4
node_modules/vant/es/notice-bar/style/index.js
generated
vendored
Normal file
4
node_modules/vant/es/notice-bar/style/index.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import '../../style/base.css';
|
||||
import '../../info/index.css';
|
||||
import '../../icon/index.css';
|
||||
import '../index.css';
|
4
node_modules/vant/es/notice-bar/style/less.js
generated
vendored
Normal file
4
node_modules/vant/es/notice-bar/style/less.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import '../../style/base.less';
|
||||
import '../../info/index.less';
|
||||
import '../../icon/index.less';
|
||||
import '../index.less';
|
Reference in New Issue
Block a user