previewFoundation.ts 840 B

12345678910111213141516171819202122232425
  1. import BaseFoundation, { DefaultAdapter } from "../base/foundation";
  2. export default class PreviewFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<Partial<DefaultAdapter>> {
  3. handleVisibleChange = (newVisible : boolean) => {
  4. const { visible, onVisibleChange } = this.getProps();
  5. if (!(visible in this.getProps())) {
  6. this.setState({
  7. visible: newVisible,
  8. });
  9. }
  10. onVisibleChange && onVisibleChange(newVisible);
  11. };
  12. handleCurrentIndexChange = (index: number) => {
  13. const { currentIndex, onChange } = this.getProps();
  14. if (!(currentIndex in this.getProps())) {
  15. this.setState({
  16. currentIndex: index,
  17. } as any);
  18. }
  19. onChange && onChange(index);
  20. };
  21. }