Skip to content

Commit

Permalink
Merge 77e2380 into 9eb5fc3
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Oct 23, 2018
2 parents 9eb5fc3 + 77e2380 commit bc928db
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions declaration/browser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare let win: any;
export { win as window };
export declare const document: any;
2 changes: 1 addition & 1 deletion declaration/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare function toArray(nodes: NodeList): HTMLElement[];
export declare function $(param: any, multi?: boolean): any;
export declare function requestAnimationFrame(fp: any): number;
export declare function requestAnimationFrame(fp: any): any;
export declare function cancelAnimationFrame(key: any): void;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"scripts": {
"start": "webpack-dev-server --open",
"build:webpack": "webpack --env production && webpack --env packaged && npm run declaration",
"build": "rollup -c && npm run declaration",
"build": "rollup -c && npm run declaration && npm run test:node",
"test": "karma start",
"test:node": "node ./dist/axes.pkgd.js",
"test:chrome": "karma start --chrome",
"lint": "tslint -c tslint.json -p tsconfig.json",
"jsdoc": "rm -rf ./doc && rm -rf outjs && tsc -p tsconfig.json && jsdoc -c jsdoc.json",
Expand Down
13 changes: 13 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable no-new-func, no-nested-ternary */

let win: any;

if (typeof window === "undefined") {
// window is undefined in node.js
win = {};
} else {
win = window;
}
/* eslint-enable no-new-func, no-nested-ternary */

export {win as window};
3 changes: 3 additions & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export {
} from "@egjs/hammerjs";

export const TRANSFORM = (() => {
if (typeof document === "undefined") {
return "";
}
const bodyStyle = (document.head || document.getElementsByTagName("head")[0]).style;
const target = ["transform", "webkitTransform", "msTransform", "mozTransform"];
for (let i = 0, len = target.length; i < len; i++) {
Expand Down
1 change: 1 addition & 0 deletions src/inputType/InputType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Manager, PointerEventInput, TouchMouseInput, TouchInput, MouseInput} from "@egjs/hammerjs";
import { Axis } from "../AxisManager";
import { AxesOption } from "../Axes";
import { window } from "../browser";

export interface IInputType {
axes: string[];
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {window} from "./browser";

declare var jQuery: any;

export function toArray(nodes: NodeList): HTMLElement[] {
Expand Down

0 comments on commit bc928db

Please sign in to comment.