forked from DefinitelyTyped/DefinitelyTyped
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sonar-js): new definition file (DefinitelyTyped#46486)
- definition file - tests https://github.com/brandonweiss/sonar-js Thanks!
- Loading branch information
1 parent
d046b35
commit 44f519e
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Type definitions for sonar-js 1.1 | ||
// Project: https://github.com/brandonweiss/sonar-js | ||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
export as namespace Sonar; | ||
|
||
/** | ||
* A tiny library for detecting when a browser is scrolled to the bottom of a web page. | ||
* | ||
* You could use this, for example, on a blog to show a popover when a reader has finished a post, | ||
* letting them know they can receive new posts by email if they submit their email address. | ||
*/ | ||
declare class Sonar { | ||
withinRangeOfPageBottom?: boolean; | ||
|
||
constructor(window: Window); | ||
|
||
ping(range: number, bottomFoundCallback?: Sonar.SonarCallback, bottomLostCallback?: Sonar.SonarCallback): void; | ||
|
||
stop(): void; | ||
} | ||
|
||
declare namespace Sonar { | ||
type SonarCallback = () => void; | ||
} | ||
|
||
export = Sonar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Sonar = require('sonar-js'); | ||
|
||
const sonar = new Sonar(window); | ||
|
||
const withinRangeOfPageBottom = () => { | ||
document.querySelector('.popover')!.classList.remove('hidden'); | ||
}; | ||
|
||
const notWithinRangeOfPageBottom = () => { | ||
document.querySelector('.popover')!.classList.add('hidden'); | ||
}; | ||
|
||
sonar.ping(600, withinRangeOfPageBottom, notWithinRangeOfPageBottom); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6", | ||
"DOM" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"sonar-js-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |