Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
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
梁杰芳
slm-fileview
Commits
e4407467
Commit
e4407467
authored
Jul 16, 2019
by
1045485954@qq.com
Committed by
kl
Jul 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IE兼容性问题,目前已兼容到IE9
parent
551eeb03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
28 deletions
+52
-28
lazyload.js
jodconverter-web/src/main/resources/static/js/lazyload.js
+52
-28
No files found.
jodconverter-web/src/main/resources/static/js/lazyload.js
View file @
e4407467
function
isInSight
(
el
)
{
function
isInSight
(
el
)
{
const
bound
=
el
.
getBoundingClientRect
();
var
bound
=
el
.
getBoundingClientRect
();
const
clientHeight
=
window
.
innerHeight
;
var
clientHeight
=
window
.
innerHeight
;
//只考虑向下滚动加载
//只考虑向下滚动加载
//const clientWidth=window.innerWeight;
//const clientWidth=window.innerWeight;
return
bound
.
top
<=
clientHeight
+
100
;
return
bound
.
top
<=
clientHeight
+
100
;
}
}
let
index
=
0
;
var
index
=
0
;
function
checkImgs
()
{
function
checkImgs
()
{
const
imgs
=
document
.
querySelectorAll
(
'.my-photo'
);
var
imgs
=
document
.
querySelectorAll
(
'.my-photo'
);
for
(
let
i
=
index
;
i
<
imgs
.
length
;
i
++
)
{
for
(
var
i
=
index
;
i
<
imgs
.
length
;
i
++
)
{
if
(
isInSight
(
imgs
[
i
]))
{
if
(
isInSight
(
imgs
[
i
]))
{
loadImg
(
imgs
[
i
]);
loadImg
(
imgs
[
i
]);
index
=
i
;
index
=
i
;
}
}
}
}
}
}
function
loadImg
(
el
)
{
function
loadImg
(
el
)
{
const
source
=
el
.
dataset
.
src
;
var
source
=
el
.
getAttribute
(
"data-src"
)
;
el
.
src
=
source
;
el
.
src
=
source
;
}
}
// var mustRun = 500
// function throttle(fn, mustRun) {
// var timer = null;
// var previous = null;
// return function() {
// var now = new Date();
// var context = this;
// var args = arguments;
// if (!previous) {
// previous = now;
// }
// var remaining = now - previous;
// if (mustRun && remaining >= mustRun) {
// fn.apply(context, args);
// previous = now;
// }
// }
// }
function
throttle
(
fn
,
mustRun
=
500
)
{
function
throttle
(
fn
)
{
const
timer
=
null
;
var
timer
=
null
;
let
previous
=
null
;
var
previous
=
null
;
return
function
()
{
return
function
()
{
const
now
=
new
Date
();
var
now
=
new
Date
();
const
context
=
this
;
var
context
=
this
;
const
args
=
arguments
;
var
args
=
arguments
;
if
(
!
previous
)
{
if
(
!
previous
)
{
previous
=
now
;
previous
=
now
;
}
var
remaining
=
now
-
previous
;
setTimeout
(
refresh
(
fn
,
remaining
,
context
,
args
,
previous
,
now
));
}
}
const
remaining
=
now
-
previous
;
}
if
(
mustRun
&&
remaining
>=
mustRun
)
{
fn
.
apply
(
context
,
args
);
function
refresh
(
fn
,
remaining
,
context
,
args
,
previous
,
now
)
{
previous
=
now
;
if
(
remaining
>=
500
)
{
fn
.
apply
(
context
,
args
);
previous
=
now
;
}
}
}
}
}
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