Ejemplo n.º 1
0
  render () {
    const { items, style, placement, arrowOffsetLeft, arrowOffsetTop } = this.props;

    return (
      <Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
        {({ opacity, scaleX, scaleY }) => (
          <div className='dropdown-menu' style={{ ...style, opacity: opacity, transform: `scale(${scaleX}, ${scaleY})` }} ref={this.setRef}>
            <div className={`dropdown-menu__arrow ${placement}`} style={{ left: arrowOffsetLeft, top: arrowOffsetTop }} />

            <ul>
              {items.map((option, i) => this.renderItem(option, i))}
            </ul>
          </div>
        )}
      </Motion>
    );
  }
Ejemplo n.º 2
0
  render () {
    const { items, style, placement, arrowOffsetLeft, arrowOffsetTop } = this.props;
    const { mounted } = this.state;

    return (
      <Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
        {({ opacity, scaleX, scaleY }) => (
          // It should not be transformed when mounting because the resulting
          // size will be used to determine the coordinate of the menu by
          // react-overlays
          <div className='dropdown-menu' style={{ ...style, opacity: opacity, transform: mounted ? `scale(${scaleX}, ${scaleY})` : null }} ref={this.setRef}>
            <div className={`dropdown-menu__arrow ${placement}`} style={{ left: arrowOffsetLeft, top: arrowOffsetTop }} />

            <ul>
              {items.map((option, i) => this.renderItem(option, i))}
            </ul>
          </div>
        )}
      </Motion>
    );
  }
Ejemplo n.º 3
0
	render() {
		let {delta, isPressed, active, nav} = this.state;
		let x = active == 0 ? delta : (delta - clientW);
		let _style = isPressed ? {x: x} : {x: spring(active, springConfig)};
		return (
			<div>
				<header>
					<div className={classnames(style.tabs,'clearfix')}>
						<div onClick={this.onNavChange.bind(this,0)} className={active == 0 ? style.active:''}>分类</div>
						<div onClick={this.onNavChange.bind(this,1)} className={active !=0 ?style.active:''}>品牌</div>
						<Motion style={_style}>
							{({x}) =>
						<div className={style.bar}
								 style={{
								 transform: `translate3d(${-x/2}px,0,0)`,
								 WebkitTransform: `translate3d(${-x/2}px,0,0)`
							 }}></div>
							}
						</Motion>
					</div>
				</header>
				<Motion style={_style}>
					{({x}) =>
						<div className={style.container}
								 onMouseDown={this.handleMouseDown}
								 onMouseMove={this.handleMouseMove}
								 onMouseUp={this.handleMouseUp}
								 onTouchStart={this.handleTouchStart}
								 onTouchMove={this.handleTouchMove}
								 onTouchEnd={this.handleMouseUp}
								 style={{
								 	transform: `translate3d(${x}px,0,0)`,
								 	WebkitTransform: `translate3d(${x}px,0,0)`
								 }}>
							<Category />
							<Brand />
						</div>
					}
				</Motion>
			</div>
		);
	}
Ejemplo n.º 4
0
  render () {
    const style = {
      fontSize: `${this.props.size}px`,
      width: `${this.props.size * 1.28571429}px`,
      height: `${this.props.size * 1.28571429}px`,
      lineHeight: `${this.props.size}px`,
      ...this.props.style,
      ...(this.props.active ? this.props.activeStyle : {}),
    };

    const {
      active,
      animate,
      className,
      disabled,
      expanded,
      icon,
      inverted,
      overlay,
      pressed,
      tabIndex,
      title,
    } = this.props;

    const classes = classNames(className, 'icon-button', {
      active,
      disabled,
      inverted,
      overlayed: overlay,
    });

    if (!animate) {
      // Perf optimization: avoid unnecessary <Motion> components unless
      // we actually need to animate.
      return (
        <button
          aria-label={title}
          aria-pressed={pressed}
          aria-expanded={expanded}
          title={title}
          className={classes}
          onClick={this.handleClick}
          style={style}
          tabIndex={tabIndex}
        >
          <i className={`fa fa-fw fa-${icon}`} aria-hidden='true' />
        </button>
      );
    }

    return (
      <Motion defaultStyle={{ rotate: active ? -360 : 0 }} style={{ rotate: animate ? spring(active ? -360 : 0, { stiffness: 120, damping: 7 }) : 0 }}>
        {({ rotate }) =>
          <button
            aria-label={title}
            aria-pressed={pressed}
            aria-expanded={expanded}
            title={title}
            className={classes}
            onClick={this.handleClick}
            style={style}
            tabIndex={tabIndex}
          >
            <i style={{ transform: `rotate(${rotate}deg)` }} className={`fa fa-fw fa-${icon}`} aria-hidden='true' />
          </button>
        }
      </Motion>
    );
  }