提交 5888258e 编写于 作者: Q qiang

Merge branch 'mouse-optimization' into dev

...@@ -131,6 +131,7 @@ export default { ...@@ -131,6 +131,7 @@ export default {
overflow: hidden; overflow: hidden;
color: #000000; color: #000000;
background-color: #F8F8F8; background-color: #F8F8F8;
cursor: pointer;
} }
uni-button[hidden] { uni-button[hidden] {
...@@ -192,6 +193,7 @@ export default { ...@@ -192,6 +193,7 @@ export default {
uni-button[disabled] { uni-button[disabled] {
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.6);
cursor: not-allowed;
} }
uni-button[disabled][type=default], uni-button[disabled][type=default],
...@@ -287,6 +289,10 @@ export default { ...@@ -287,6 +289,10 @@ export default {
padding: 0 1.34em; padding: 0 1.34em;
} }
uni-button[loading]:not([disabled]){
cursor: progress;
}
uni-button[loading]:before { uni-button[loading]:before {
content: " "; content: " ";
display: inline-block; display: inline-block;
...@@ -375,4 +381,4 @@ export default { ...@@ -375,4 +381,4 @@ export default {
border-color: rgba(230, 67, 64, 0.6); border-color: rgba(230, 67, 64, 0.6);
background-color: transparent; background-color: transparent;
} }
</style> </style>
<template> <template>
<uni-checkbox <uni-checkbox
v-on="$listeners" :disabled="disabled"
v-on="$listeners"
@click="_onClick"> @click="_onClick">
<div class="uni-checkbox-wrapper"> <div class="uni-checkbox-wrapper">
<div <div
:class="[checkboxChecked ? 'uni-checkbox-input-checked' : '']" :class="[checkboxChecked ? 'uni-checkbox-input-checked' : '']"
:style="{color:color}" :style="{color:color}"
class="uni-checkbox-input" /> class="uni-checkbox-input" />
<slot /> <slot />
</div> </div>
...@@ -97,12 +98,17 @@ export default { ...@@ -97,12 +98,17 @@ export default {
uni-checkbox { uni-checkbox {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
display: inline-block; display: inline-block;
cursor: pointer;
} }
uni-checkbox[hidden] { uni-checkbox[hidden] {
display: none; display: none;
} }
uni-checkbox[disabled] {
cursor: not-allowed;
}
uni-checkbox .uni-checkbox-wrapper { uni-checkbox .uni-checkbox-wrapper {
display: -webkit-inline-flex; display: -webkit-inline-flex;
display: inline-flex; display: inline-flex;
...@@ -124,6 +130,10 @@ export default { ...@@ -124,6 +130,10 @@ export default {
position: relative; position: relative;
} }
uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
border-color: #007aff;
}
uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked { uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked {
color: #007aff; color: #007aff;
} }
...@@ -150,4 +160,4 @@ export default { ...@@ -150,4 +160,4 @@ export default {
uni-checkbox-group { uni-checkbox-group {
display: block; display: block;
} }
</style> </style>
<template> <template>
<uni-label <uni-label
:class="{'uni-label-pointer':pointer}"
v-on="$listeners" v-on="$listeners"
@click="_onClick"> @click="_onClick">
<slot /> <slot />
...@@ -18,6 +19,11 @@ export default { ...@@ -18,6 +19,11 @@ export default {
default: '' default: ''
} }
}, },
computed: {
pointer () {
return this.for || (this.$slots.default && this.$slots.default.length)
}
},
methods: { methods: {
_onClick ($event) { _onClick ($event) {
let stopPropagation = /^uni-(checkbox|radio|switch)-/.test($event.target.className) let stopPropagation = /^uni-(checkbox|radio|switch)-/.test($event.target.className)
...@@ -38,5 +44,7 @@ export default { ...@@ -38,5 +44,7 @@ export default {
} }
</script> </script>
<style> <style>
.uni-label-pointer {
</style> cursor: pointer;
}
</style>
...@@ -11,8 +11,8 @@ import { ...@@ -11,8 +11,8 @@ import {
Friction, Friction,
STD STD
} from './utils' } from './utils'
import { import {
disableScrollBounce disableScrollBounce
} from 'uni-shared' } from 'uni-shared'
var requesting = false var requesting = false
...@@ -658,6 +658,7 @@ uni-movable-view { ...@@ -658,6 +658,7 @@ uni-movable-view {
top: 0px; top: 0px;
left: 0px; left: 0px;
position: absolute; position: absolute;
cursor: grab;
} }
uni-movable-view[hidden] { uni-movable-view[hidden] {
......
<template> <template>
<uni-navigator <uni-navigator
v-if="hoverClass && hoverClass !== 'none'" v-if="hoverClass && hoverClass !== 'none'"
:class="[hovering ? hoverClass : '']" :class="[hovering ? hoverClass : '']"
@touchstart="_hoverTouchStart" @touchstart="_hoverTouchStart"
@touchend="_hoverTouchEnd" @touchend="_hoverTouchEnd"
@touchcancel="_hoverTouchCancel" @touchcancel="_hoverTouchCancel"
@click="_onClick" @click="_onClick"
v-on="$listeners"> v-on="$listeners">
<slot /> <slot />
</uni-navigator> </uni-navigator>
<uni-navigator <uni-navigator
v-else v-else
@click="_onClick" @click="_onClick"
v-on="$listeners"> v-on="$listeners">
<slot /> <slot />
</uni-navigator> </uni-navigator>
...@@ -97,18 +97,19 @@ export default { ...@@ -97,18 +97,19 @@ export default {
} }
</script> </script>
<style> <style>
.navigator-hover {
background-color: rgba(0, 0, 0, 0.1);
opacity: 0.7;
}
uni-navigator { uni-navigator {
height: auto; height: auto;
width: auto; width: auto;
display: block; display: block;
cursor: pointer;
} }
uni-navigator[hidden] { uni-navigator[hidden] {
display: none; display: none;
} }
</style>
.navigator-hover {
background-color: rgba(0, 0, 0, 0.1);
opacity: 0.7;
}
</style>
...@@ -13,16 +13,15 @@ import { ...@@ -13,16 +13,15 @@ import {
function initClick (dom) { function initClick (dom) {
const MAX_MOVE = 20 const MAX_MOVE = 20
const hasTouchSupport = navigator.maxTouchPoints
let x = 0 let x = 0
let y = 0 let y = 0
dom.addEventListener(hasTouchSupport ? 'touchstart' : 'mousedown', (event) => { dom.addEventListener('touchstart', (event) => {
const info = hasTouchSupport ? event.changedTouches[0] : event const info = event.changedTouches[0]
x = info.clientX x = info.clientX
y = info.clientY y = info.clientY
}) })
dom.addEventListener(hasTouchSupport ? 'touchend' : 'mouseup', (event) => { dom.addEventListener('touchend', (event) => {
const info = hasTouchSupport ? event.changedTouches[0] : event const info = event.changedTouches[0]
if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) { if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
let customEvent = new CustomEvent('click', { let customEvent = new CustomEvent('click', {
bubbles: true, bubbles: true,
...@@ -301,6 +300,7 @@ export default { ...@@ -301,6 +300,7 @@ export default {
width: 100%; width: 100%;
will-change: transform; will-change: transform;
padding: 102px 0; padding: 102px 0;
cursor: pointer;
} }
.uni-picker-view-content>* { .uni-picker-view-content>* {
......
<template> <template>
<uni-radio <uni-radio
v-on="$listeners" :disabled="disabled"
v-on="$listeners"
@click="_onClick"> @click="_onClick">
<div class="uni-radio-wrapper"> <div class="uni-radio-wrapper">
<div <div
:class="radioChecked ? 'uni-radio-input-checked' : ''" :class="radioChecked ? 'uni-radio-input-checked' : ''"
:style="radioChecked ? checkedStyle : ''" :style="radioChecked ? checkedStyle : ''"
class="uni-radio-input" /> class="uni-radio-input" />
<slot /> <slot />
</div> </div>
...@@ -102,12 +103,17 @@ export default { ...@@ -102,12 +103,17 @@ export default {
uni-radio { uni-radio {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
display: inline-block; display: inline-block;
cursor: pointer;
} }
uni-radio[hidden] { uni-radio[hidden] {
display: none; display: none;
} }
uni-radio[disabled] {
cursor: not-allowed;
}
uni-radio .uni-radio-wrapper { uni-radio .uni-radio-wrapper {
display: -webkit-inline-flex; display: -webkit-inline-flex;
display: inline-flex; display: inline-flex;
...@@ -129,6 +135,10 @@ export default { ...@@ -129,6 +135,10 @@ export default {
position: relative; position: relative;
} }
uni-radio:not([disabled]) .uni-radio-input:hover {
border-color: #007aff;
}
uni-radio .uni-radio-input.uni-radio-input-checked:before { uni-radio .uni-radio-input.uni-radio-input-checked:before {
font: normal normal normal 14px/1 "uni"; font: normal normal normal 14px/1 "uni";
content: "\EA08"; content: "\EA08";
...@@ -153,4 +163,4 @@ export default { ...@@ -153,4 +163,4 @@ export default {
uni-radio-group { uni-radio-group {
display: block; display: block;
} }
</style> </style>
<template> <template>
<uni-slider <uni-slider
ref="uni-slider" ref="uni-slider"
v-on="$listeners" v-on="$listeners"
@click="_onClick"> @click="_onClick">
<div class="uni-slider-wrapper"> <div class="uni-slider-wrapper">
<div class="uni-slider-tap-area"> <div class="uni-slider-tap-area">
<div <div
:style="setBgColor" :style="setBgColor"
class="uni-slider-handle-wrapper"> class="uni-slider-handle-wrapper">
<div <div
ref="uni-slider-handle" ref="uni-slider-handle"
:style="setBlockBg" :style="setBlockBg"
class="uni-slider-handle" /> class="uni-slider-handle" />
<div <div
:style="setBlockStyle" :style="setBlockStyle"
class="uni-slider-thumb" /> class="uni-slider-thumb" />
<div <div
:style="setActiveColor" :style="setActiveColor"
class="uni-slider-track" /> class="uni-slider-track" />
</div> </div>
</div> </div>
<span <span
v-show="showValue" v-show="showValue"
class="uni-slider-value">{{ sliderValue }}</span> class="uni-slider-value">{{ sliderValue }}</span>
</div> </div>
<slot /> <slot />
...@@ -259,6 +259,7 @@ export default { ...@@ -259,6 +259,7 @@ export default {
margin-left: -14px; margin-left: -14px;
background-color: transparent; background-color: transparent;
z-index: 3; z-index: 3;
cursor: grab;
} }
uni-slider .uni-slider-thumb { uni-slider .uni-slider-thumb {
...@@ -288,4 +289,4 @@ export default { ...@@ -288,4 +289,4 @@ export default {
background-color: #FFF; background-color: #FFF;
border-color: #ccc; border-color: #ccc;
} }
</style> </style>
...@@ -34,6 +34,7 @@ uni-swiper-item { ...@@ -34,6 +34,7 @@ uni-swiper-item {
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
cursor: grab;
} }
uni-swiper-item[hidden] { uni-swiper-item[hidden] {
......
...@@ -596,6 +596,11 @@ export default { ...@@ -596,6 +596,11 @@ export default {
for (let index = 0, length = swiperItems.length; index < length; index++) { for (let index = 0, length = swiperItems.length; index < length; index++) {
let currentSync = this.currentSync let currentSync = this.currentSync
slidesDots.push(createElement('div', { slidesDots.push(createElement('div', {
on: {
click: () => {
this._animateViewport(this.currentSync = index, this.currentChangeSource = 'click', this.circularEnabled ? 1 : 0)
}
},
class: { class: {
'uni-swiper-dot': true, 'uni-swiper-dot': true,
'uni-swiper-dot-active': (index < currentSync + this.displayMultipleItemsNumber && index >= currentSync) || (index < currentSync + this.displayMultipleItemsNumber - length) 'uni-swiper-dot-active': (index < currentSync + this.displayMultipleItemsNumber && index >= currentSync) || (index < currentSync + this.displayMultipleItemsNumber - length)
......
<template> <template>
<uni-switch <uni-switch
v-on="$listeners" :disabled="disabled"
v-on="$listeners"
@click="_onClick"> @click="_onClick">
<div class="uni-switch-wrapper"> <div class="uni-switch-wrapper">
<div <div
v-show="type === 'switch'" v-show="type === 'switch'"
:class="[switchChecked ? 'uni-switch-input-checked' : '']" :class="[switchChecked ? 'uni-switch-input-checked' : '']"
:style="{backgroundColor: switchChecked ? color : '#DFDFDF',borderColor:switchChecked ? color : '#DFDFDF'}" :style="{backgroundColor: switchChecked ? color : '#DFDFDF',borderColor:switchChecked ? color : '#DFDFDF'}"
class="uni-switch-input" /> class="uni-switch-input" />
<div <div
v-show="type === 'checkbox'" v-show="type === 'checkbox'"
:class="[switchChecked ? 'uni-checkbox-input-checked' : '']" :class="[switchChecked ? 'uni-checkbox-input-checked' : '']"
:style="{color: color}" :style="{color: color}"
class="uni-checkbox-input" /> class="uni-checkbox-input" />
</div> </div>
...@@ -105,12 +106,17 @@ export default { ...@@ -105,12 +106,17 @@ export default {
uni-switch { uni-switch {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
display: inline-block; display: inline-block;
cursor: pointer;
} }
uni-switch[hidden] { uni-switch[hidden] {
display: none; display: none;
} }
uni-switch[disabled] {
cursor: not-allowed;
}
uni-switch .uni-switch-wrapper { uni-switch .uni-switch-wrapper {
display: -webkit-inline-flex; display: -webkit-inline-flex;
display: inline-flex; display: inline-flex;
...@@ -134,6 +140,10 @@ export default { ...@@ -134,6 +140,10 @@ export default {
transition: background-color 0.1s, border 0.1s; transition: background-color 0.1s, border 0.1s;
} }
uni-switch[disabled] .uni-switch-input {
opacity: .7;
}
uni-switch .uni-switch-input:before { uni-switch .uni-switch-input:before {
content: " "; content: " ";
position: absolute; position: absolute;
...@@ -192,6 +202,10 @@ export default { ...@@ -192,6 +202,10 @@ export default {
color: #007aff; color: #007aff;
} }
uni-switch:not([disabled]) .uni-checkbox-input:hover {
border-color: #007aff;
}
uni-switch .uni-checkbox-input.uni-checkbox-input-checked:before { uni-switch .uni-checkbox-input.uni-checkbox-input-checked:before {
font: normal normal normal 14px/1 "uni"; font: normal normal normal 14px/1 "uni";
content: "\EA08"; content: "\EA08";
...@@ -211,4 +225,4 @@ export default { ...@@ -211,4 +225,4 @@ export default {
uni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before { uni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before {
color: #ADADAD; color: #ADADAD;
} }
</style> </style>
var addListenerToElement = function (element, type, callback, r) { const addListenerToElement = function (element, type, callback, capture) {
// 暂时忽略capture // 暂时忽略 capture
element.addEventListener(type, $event => { element.addEventListener(type, $event => {
if (typeof callback === 'function') { if (typeof callback === 'function') {
if (callback($event) === false) { if (callback($event) === false) {
...@@ -13,14 +13,18 @@ var addListenerToElement = function (element, type, callback, r) { ...@@ -13,14 +13,18 @@ var addListenerToElement = function (element, type, callback, r) {
} }
export default { export default {
beforeDestroy () {
document.removeEventListener('mousemove', this.__mouseMoveEventListener)
document.removeEventListener('mouseup', this.__mouseUpEventListener)
},
methods: { methods: {
touchtrack: function (element, method, useCancel) { touchtrack: function (element, method, useCancel) {
var self = this const self = this
var x0 = 0 let x0 = 0
var y0 = 0 let y0 = 0
var x1 = 0 let x1 = 0
var y1 = 0 let y1 = 0
var fn = function ($event, state, x, y) { const fn = function ($event, state, x, y) {
if (self[method]({ if (self[method]({
target: $event.target, target: $event.target,
currentTarget: $event.currentTarget, currentTarget: $event.currentTarget,
...@@ -43,8 +47,11 @@ export default { ...@@ -43,8 +47,11 @@ export default {
} }
} }
var $eventOld = null let $eventOld = null
let hasTouchStart
let hasMouseDown
addListenerToElement(element, 'touchstart', function ($event) { addListenerToElement(element, 'touchstart', function ($event) {
hasTouchStart = true
if ($event.touches.length === 1 && !$eventOld) { if ($event.touches.length === 1 && !$eventOld) {
$eventOld = $event $eventOld = $event
x0 = x1 = $event.touches[0].pageX x0 = x1 = $event.touches[0].pageX
...@@ -52,23 +59,54 @@ export default { ...@@ -52,23 +59,54 @@ export default {
return fn($event, 'start', x0, y0) return fn($event, 'start', x0, y0)
} }
}) })
addListenerToElement(element, 'mousedown', function ($event) {
hasMouseDown = true
if (!hasTouchStart && !$eventOld) {
// TODO touches changedTouches
$eventOld = $event
x0 = x1 = $event.pageX
y0 = y1 = $event.pageY
return fn($event, 'start', x0, y0)
}
})
addListenerToElement(element, 'touchmove', function ($event) { addListenerToElement(element, 'touchmove', function ($event) {
if ($event.touches.length === 1 && $eventOld) { if ($event.touches.length === 1 && $eventOld) {
var res = fn($event, 'move', $event.touches[0].pageX, $event.touches[0].pageY) const res = fn($event, 'move', $event.touches[0].pageX, $event.touches[0].pageY)
x1 = $event.touches[0].pageX x1 = $event.touches[0].pageX
y1 = $event.touches[0].pageY y1 = $event.touches[0].pageY
return res return res
} }
}) })
const mouseMoveEventListener = this.__mouseMoveEventListener = function ($event) {
if (!hasTouchStart && hasMouseDown && $eventOld) {
// TODO target currentTarget touches changedTouches
const res = fn($event, 'move', $event.pageX, $event.pageY)
x1 = $event.pageX
y1 = $event.pageY
return res
}
}
document.addEventListener('mousemove', mouseMoveEventListener)
addListenerToElement(element, 'touchend', function ($event) { addListenerToElement(element, 'touchend', function ($event) {
if ($event.touches.length === 0 && $eventOld) { if ($event.touches.length === 0 && $eventOld) {
hasTouchStart = false
$eventOld = null $eventOld = null
return fn($event, 'end', $event.changedTouches[0].pageX, $event.changedTouches[0].pageY) return fn($event, 'end', $event.changedTouches[0].pageX, $event.changedTouches[0].pageY)
} }
}) })
const mouseUpEventListener = this.__mouseUpEventListener = function ($event) {
hasMouseDown = false
if (!hasTouchStart && $eventOld) {
// TODO target currentTarget touches changedTouches
$eventOld = null
return fn($event, 'end', $event.pageX, $event.pageY)
}
}
document.addEventListener('mouseup', mouseUpEventListener)
addListenerToElement(element, 'touchcancel', function ($event) { addListenerToElement(element, 'touchcancel', function ($event) {
if ($eventOld) { if ($eventOld) {
var $eventTemp = $eventOld hasTouchStart = false
const $eventTemp = $eventOld
$eventOld = null $eventOld = null
return fn($event, useCancel ? 'cancel' : 'end', $eventTemp.touches[0].pageX, $eventTemp.touches[0].pageY) return fn($event, useCancel ? 'cancel' : 'end', $eventTemp.touches[0].pageX, $eventTemp.touches[0].pageY)
} }
......
...@@ -100,6 +100,7 @@ uni-tabbar .uni-tabbar__bd { ...@@ -100,6 +100,7 @@ uni-tabbar .uni-tabbar__bd {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer;
} }
uni-tabbar .uni-tabbar__icon { uni-tabbar .uni-tabbar__icon {
......
...@@ -175,6 +175,7 @@ uni-page-head .uni-page-head-bd { ...@@ -175,6 +175,7 @@ uni-page-head .uni-page-head-bd {
margin: 0 2px; margin: 0 2px;
word-break: keep-all; word-break: keep-all;
white-space: pre; white-space: pre;
cursor: pointer;
} }
.uni-page-head-transparent .uni-page-head-btn { .uni-page-head-transparent .uni-page-head-btn {
......
<template> <template>
<uni-picker <uni-picker
:disabled="disabled"
@click.stop="_show" @click.stop="_show"
v-on="$listeners"> v-on="$listeners">
<div <div
...@@ -438,6 +439,15 @@ export default { ...@@ -438,6 +439,15 @@ export default {
<style> <style>
uni-picker { uni-picker {
display: block; display: block;
cursor: pointer;
}
uni-picker[hidden] {
display: none;
}
uni-picker[disabled] {
cursor: not-allowed;
} }
.uni-picker-container { .uni-picker-container {
...@@ -526,6 +536,7 @@ uni-picker { ...@@ -526,6 +536,7 @@ uni-picker {
font-size: 17px; font-size: 17px;
line-height: 45px; line-height: 45px;
overflow: hidden; overflow: hidden;
cursor: pointer;
} }
.uni-picker-container .uni-picker-action.uni-picker-action-cancel { .uni-picker-container .uni-picker-action.uni-picker-action-cancel {
......
...@@ -787,6 +787,7 @@ uni-video[hidden] { ...@@ -787,6 +787,7 @@ uni-video[hidden] {
background-size: 50%; background-size: 50%;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 50% 50%; background-position: 50% 50%;
cursor: pointer;
} }
.uni-video-cover-duration { .uni-video-cover-duration {
...@@ -831,6 +832,7 @@ uni-video[hidden] { ...@@ -831,6 +832,7 @@ uni-video[hidden] {
padding: 14.5px 12.5px 14.5px 12.5px; padding: 14.5px 12.5px 14.5px 12.5px;
margin-left: -8.5px; margin-left: -8.5px;
box-sizing: content-box; box-sizing: content-box;
cursor: pointer;
} }
.uni-video-control-button::after { .uni-video-control-button::after {
...@@ -873,6 +875,7 @@ uni-video[hidden] { ...@@ -873,6 +875,7 @@ uni-video[hidden] {
margin: 21px 12px; margin: 21px 12px;
background-color: rgba(255, 255, 255, 0.4); background-color: rgba(255, 255, 255, 0.4);
position: relative; position: relative;
cursor: pointer;
} }
.uni-video-progress-buffered { .uni-video-progress-buffered {
...@@ -912,6 +915,7 @@ uni-video[hidden] { ...@@ -912,6 +915,7 @@ uni-video[hidden] {
font-size: 13px; font-size: 13px;
color: #fff; color: #fff;
margin: 0 8.5px; margin: 0 8.5px;
cursor: pointer;
} }
.uni-video-danmu-button.uni-video-danmu-button-active { .uni-video-danmu-button.uni-video-danmu-button-active {
...@@ -928,6 +932,7 @@ uni-video[hidden] { ...@@ -928,6 +932,7 @@ uni-video[hidden] {
background-size: 50%; background-size: 50%;
background-position: 50% 50%; background-position: 50% 50%;
background-repeat: no-repeat; background-repeat: no-repeat;
cursor: pointer;
} }
.uni-video-fullscreen.uni-video-type-fullscreen { .uni-video-fullscreen.uni-video-type-fullscreen {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册