Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-easy-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
easyUI
hls-easy-ui
Commits
1ef300f1
Commit
1ef300f1
authored
Dec 16, 2019
by
JingChao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
键盘高度
parent
153ca5b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
4 deletions
+63
-4
index.vue
packages/components/HContent/index.vue
+63
-4
No files found.
packages/components/HContent/index.vue
View file @
1ef300f1
...
@@ -4,13 +4,15 @@
...
@@ -4,13 +4,15 @@
*/
*/
<
template
>
<
template
>
<div
class=
"content"
>
<div
class=
"content"
@
touchstart
.
capture=
"touchStart"
@
touchend
.
capture=
"touchEnd"
>
<slot/>
<slot/>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
detectOS
}
from
'../../common/utils/index'
import
{
detectOS
}
from
'../../common/utils/index'
export
default
{
export
default
{
name
:
'HContent'
,
name
:
'HContent'
,
props
:
{
props
:
{
...
@@ -22,16 +24,62 @@ export default {
...
@@ -22,16 +24,62 @@ export default {
data
()
{
data
()
{
return
{
return
{
fontSize
:
Number
(
window
.
document
.
documentElement
.
style
.
fontSize
.
replace
(
'px'
,
''
)),
fontSize
:
Number
(
window
.
document
.
documentElement
.
style
.
fontSize
.
replace
(
'px'
,
''
)),
winHeight
:
window
.
innerHeight
,
winHeight
:
Number
(
window
.
localStorage
.
getItem
(
'height'
))
||
window
.
innerHeight
,
winWidth
:
window
.
innerWidth
,
winWidth
:
window
.
innerWidth
,
height
:
0
,
startY
:
0
,
endY
:
0
,
}
}
},
},
mounted
()
{
mounted
()
{
let
vm
=
this
if
(
this
.
calContent
)
{
if
(
this
.
calContent
)
{
this
.
contentHeight
()
this
.
contentHeight
()
}
}
window
.
addEventListener
(
'native.keyboardshow'
,
function
(
e
)
{
setTimeout
(
function
()
{
if
(
detectOS
()
===
'android'
)
{
vm
.
$el
.
style
.
transition
=
'all .2s cubic-bezier(0.165, 0.84, 0.44, 1) 0s'
vm
.
$el
.
style
.
transform
=
'translate(0px, -45px) scale(1) translateZ(0px)'
}
else
{
let
keyBoardHeight
=
vm
.
getKeyBoardHeight
()
let
scollHeight
=
(
innerHeight
-
vm
.
endY
)
<
keyBoardHeight
?
(
keyBoardHeight
-
(
innerHeight
-
vm
.
endY
))
:
0
if
(
scollHeight
)
{
vm
.
$el
.
style
.
paddingBottom
=
(
scollHeight
+
20
)
+
'px'
vm
.
$el
.
style
.
transition
=
'all .2s cubic-bezier(0.165, 0.84, 0.44, 1) 0s'
vm
.
$el
.
style
.
transform
=
'translate(0px, -'
+
scollHeight
+
'px) scale(1) translateZ(0px)'
}
}
},
300
)
})
window
.
addEventListener
(
'native.keyboardhide'
,
function
(
e
)
{
setTimeout
(
function
()
{
vm
.
$el
.
style
.
transition
=
'all .2s cubic-bezier(0.165, 0.84, 0.44, 1) 0s'
vm
.
$el
.
style
.
transform
=
'translate(0px, 0px) scale(1) translateZ(0px)'
vm
.
$el
.
style
.
paddingBottom
=
'0px'
},
300
)
})
},
},
methods
:
{
methods
:
{
touchStart
(
event
)
{
if
(
detectOS
()
===
'ios'
)
{
if
(
event
.
target
.
readOnly
)
return
if
(
event
.
target
.
nodeName
===
'INPUT'
||
event
.
target
.
nodeName
===
'TEXTAREA'
)
{
this
.
startY
=
event
.
changedTouches
[
0
].
clientY
}
}
},
touchEnd
(
event
)
{
if
(
detectOS
()
===
'ios'
)
{
if
(
event
.
target
.
readOnly
)
return
if
(
event
.
target
.
nodeName
===
'INPUT'
||
event
.
target
.
nodeName
===
'TEXTAREA'
)
{
this
.
endY
=
event
.
changedTouches
[
0
].
clientY
}
}
},
getHeaderHeight
()
{
getHeaderHeight
()
{
let
vm
=
this
let
vm
=
this
let
$el
=
vm
.
$el
.
previousElementSibling
let
$el
=
vm
.
$el
.
previousElementSibling
...
@@ -55,7 +103,6 @@ export default {
...
@@ -55,7 +103,6 @@ export default {
$el
=
$el
.
previousElementSibling
$el
=
$el
.
previousElementSibling
}
}
}
while
(
$el
)
}
while
(
$el
)
return
headerHeight
return
headerHeight
},
},
getNextElementHeight
()
{
getNextElementHeight
()
{
...
@@ -91,7 +138,19 @@ export default {
...
@@ -91,7 +138,19 @@ export default {
const
headerHeight
=
vm
.
getHeaderHeight
()
const
headerHeight
=
vm
.
getHeaderHeight
()
const
nextHeight
=
vm
.
getNextElementHeight
()
const
nextHeight
=
vm
.
getNextElementHeight
()
let
content
=
vm
.
$el
let
content
=
vm
.
$el
content
.
style
.
height
=
(
window
.
innerHeight
-
nextHeight
-
headerHeight
)
+
'px'
vm
.
height
=
(
vm
.
winHeight
-
nextHeight
-
headerHeight
)
content
.
style
.
height
=
(
vm
.
winHeight
-
nextHeight
-
headerHeight
)
+
'px'
},
getKeyBoardHeight
()
{
let
innerWidth
=
window
.
innerWidth
if
(
detectOS
()
===
'ios'
)
{
if
(
innerWidth
>=
375
&&
innerHeight
>=
812
)
{
return
460
}
return
400
}
else
{
return
275
}
},
},
},
},
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment