-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from ecomfe/dev-ts
santd 2.0
- Loading branch information
Showing
641 changed files
with
14,608 additions
and
8,621 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 |
---|---|---|
|
@@ -6,6 +6,8 @@ output/ | |
node_modules/ | ||
**/node_modules/ | ||
dest/ | ||
dist/ | ||
types/ | ||
build/ | ||
npm-debug.log | ||
package-lock.json | ||
|
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
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,8 @@ | ||
#!/bin/sh | ||
|
||
# 清空编译产物 | ||
rm -rf dist types | ||
|
||
# 编译 ts | ||
pnpm build:esm | ||
pnpm build:cjs |
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
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
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
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
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
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 |
---|---|---|
|
@@ -3,63 +3,59 @@ | |
* @author fuqiangqiang <[email protected]> | ||
*/ | ||
|
||
import san, {DataTypes} from 'san'; | ||
import Base from 'santd/base'; | ||
import {classCreator} from '../core/util'; | ||
import {on, off, getScrollTop, getOffset} from '../core/util/dom'; | ||
import './style/index'; | ||
import {State, Props, ObjectDetail, Scroller} from './interface' | ||
|
||
const outerCls = classCreator('affix-outer')(); | ||
const innerCls = classCreator('affix')(); | ||
|
||
export default san.defineComponent({ | ||
dataTypes: { | ||
offsetTop: DataTypes.oneOfType([DataTypes.string, DataTypes.number]), | ||
offsetBottom: DataTypes.oneOfType([DataTypes.string, DataTypes.number]), | ||
target: DataTypes.func | ||
}, | ||
|
||
initData() { | ||
export default class Affix extends Base<State, Props> { | ||
_scroller: Scroller; | ||
initData(): State { | ||
return { | ||
affix: false, | ||
styles: {}, | ||
offsetTop: 0, | ||
offsetBottom: 0, | ||
outerStyles: {} | ||
}; | ||
}, | ||
} | ||
attached() { | ||
if (!this._scroller) { | ||
this._scroller = this.handleScroll.bind(this); | ||
|
||
const target = this.data.get('target'); | ||
const target: any = this.data.get('target'); | ||
const element = target ? target() : window; | ||
on(element, 'scroll', this._scroller); | ||
on(element, 'resize', this._scroller); | ||
} | ||
}, | ||
} | ||
|
||
disposed() { | ||
disposed(): void { | ||
if (this._scroller) { | ||
const target = this.data.get('target'); | ||
const element = target ? target() : window; | ||
const element: any = target ? target() : window; | ||
off(element, 'scroll', this._scroller); | ||
off(element, 'resize', this._scroller); | ||
this._scroller = null; | ||
this._scroller = null as unknown as Scroller; | ||
} | ||
}, | ||
} | ||
|
||
handleScroll() { | ||
const target = this.data.get('target'); | ||
const target: any = this.data.get('target'); | ||
const targetOffset = target && getOffset(target()); | ||
const elOffset = getOffset(this.el); | ||
const scrollTop = getScrollTop(); | ||
const innerEl = this.ref('inner'); | ||
|
||
let offsetTop = +this.data.get('offsetTop'); | ||
let offsetBottom = +this.data.get('offsetBottom'); | ||
const innerEl: any = this.ref('inner'); | ||
let offsetTop = this.data.get('offsetTop') || 0; | ||
let offsetBottom = this.data.get('offsetBottom') || 0; | ||
let isAffixBottom = offsetBottom >= 0; | ||
|
||
let affixTo = null; | ||
let styles = {}; | ||
let styles: ObjectDetail = {}; | ||
let outerStyles = {}; | ||
|
||
if (isAffixBottom) { | ||
|
@@ -106,13 +102,13 @@ export default san.defineComponent({ | |
this.data.set('affix', affixTo); | ||
this.fire('change', affixTo); | ||
} | ||
}, | ||
} | ||
|
||
template: ` | ||
static template = ` | ||
<div class="${outerCls}" style="{{outerStyles}}"> | ||
<div class="{{affix ? '${innerCls}' : ''}}" style="{{styles}}" s-ref="inner"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
` | ||
}); | ||
}; |
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,21 @@ | ||
export type Target = () => HTMLElement | Window; | ||
|
||
export type ObjectDetail = {[key: string]: string}; | ||
|
||
export type Scroller = (() => void) | null | undefined; | ||
|
||
export interface State { | ||
offsetBottom?: number; | ||
offsetTop?: number; | ||
affix?: boolean; | ||
styles?: ObjectDetail; | ||
outerStyles?: ObjectDetail; | ||
|
||
} | ||
|
||
export interface Props { | ||
offsetBottom?: number; | ||
offsetTop?: number; | ||
target?: Target; | ||
styles?: ObjectDetail; | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
/** | ||
* @file 组件 alert | ||
* @author baozhixin <[email protected]> | ||
*/ | ||
* @file Santd backtop docs file | ||
**/ | ||
|
||
import san from 'san'; | ||
import Head from './head.md'; | ||
import Basic from './basic.md'; | ||
import Style from './style.md'; | ||
|
@@ -15,10 +13,10 @@ import Banner from './banner.md'; | |
import Smooth from './smooth-closed.md'; | ||
import Custom from './custom-icon.md'; | ||
import Readme from '../README.md'; | ||
import './index.less'; | ||
import Base from 'santd/base'; | ||
|
||
export default san.defineComponent({ | ||
template: ` | ||
export default class extends Base { | ||
static template = ` | ||
<div> | ||
<head/> | ||
<basic/> | ||
|
@@ -32,8 +30,9 @@ export default san.defineComponent({ | |
<custom/> | ||
<readme/> | ||
</div> | ||
`, | ||
components: { | ||
`; | ||
|
||
static components = { | ||
head: Head, | ||
basic: Basic, | ||
style: Style, | ||
|
@@ -45,5 +44,5 @@ export default san.defineComponent({ | |
smooth: Smooth, | ||
custom: Custom, | ||
readme: Readme | ||
} | ||
}); | ||
}; | ||
}; |
Oops, something went wrong.