File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -222,10 +222,10 @@ function offsetRect (rect, offset) {
222222 return rect ;
223223 }
224224 var offsetObject = {
225- top : isPercent ( offset [ 0 ] ) ? ( parseFloat ( offset [ 0 ] ) * rect . height ) : offset [ 0 ] ,
226- right : isPercent ( offset [ 1 ] ) ? ( parseFloat ( offset [ 1 ] ) * rect . width ) : offset [ 1 ] ,
227- bottom : isPercent ( offset [ 2 ] ) ? ( parseFloat ( offset [ 2 ] ) * rect . height ) : offset [ 2 ] ,
228- left : isPercent ( offset [ 3 ] ) ? ( parseFloat ( offset [ 3 ] ) * rect . width ) : offset [ 3 ]
225+ top : isPercent ( offset [ 0 ] ) ? ( parseFloat ( offset [ 0 ] ) * rect . height / 100 ) : offset [ 0 ] ,
226+ right : isPercent ( offset [ 1 ] ) ? ( parseFloat ( offset [ 1 ] ) * rect . width / 100 ) : offset [ 1 ] ,
227+ bottom : isPercent ( offset [ 2 ] ) ? ( parseFloat ( offset [ 2 ] ) * rect . height / 100 ) : offset [ 2 ] ,
228+ left : isPercent ( offset [ 3 ] ) ? ( parseFloat ( offset [ 3 ] ) * rect . width / 100 ) : offset [ 3 ]
229229 } ;
230230 // Note: ClientRect object does not allow its properties to be written to therefore a new object has to be created.
231231 return {
Original file line number Diff line number Diff line change @@ -212,6 +212,25 @@ describe("angular-inview", function() {
212212 . then ( done ) ;
213213 } ) ;
214214
215+ it ( "should consider percent offset option" , function ( done ) {
216+ makeTestForHtml (
217+ '<div in-view="spy($inviewInfo)" style="height:200px" in-view-options="{ offset:[\'25%\', 0], generateParts: true }"></div>' +
218+ '<div style="height:200%"></div>'
219+ )
220+ . then ( function ( test ) {
221+ var info = test . spy . calls . argsFor ( 0 ) [ 0 ] ;
222+ expect ( info . inView ) . toEqual ( true ) ;
223+ expect ( info . parts ) . toEqual ( {
224+ top : false ,
225+ left : true ,
226+ bottom : true ,
227+ right : true
228+ } ) ;
229+ return test ;
230+ } )
231+ . then ( done ) ;
232+ } ) ;
233+
215234 it ( "should consider viewport offset options" , function ( done ) {
216235 makeTestForHtml (
217236 '<div in-view="spy($inviewInfo)" style="height:200px" in-view-options="{ viewportOffset:[100, 0], generateParts: true }"></div>' +
You can’t perform that action at this time.
0 commit comments