【问题标题】:clap count moment issue for Ionic3Ionic3 的拍手计数问题
【发布时间】:2018-09-18 19:53:43
【问题描述】:

我将我的大学项目用于 `ionic-3,并尝试制作这样的项目。 example 看看我的代码StackBlitz 我有一些问题,我想知道如何制作 当我点击拍手图标想从底部移动到顶部计数圈时,看看我的例子它不移动总是显示那一刻,请帮我修复它

谢谢

代码部分 html

          <ion-col  tappable text-center >
            <div class="claps" style="margin-top: -1.5rem;">


              <button #clap class="clap" (click)="repeatClapping()" (mousedown)="onClapMouseDown()" (mouseup)="onClapMouseUp()">
  <span>
    <svg [class.checked]="clapIconChecked" xmlns="http://www.w3.org/2000/svg" viewBox="-549 338 100.1 125">
      <path d="M-471.2 366.8c1.2 1.1 1.9 2.6 2.3 4.1.4-.3.8-.5 1.2-.7 1-1.9.7-4.3-1-5.9-2-1.9-5.2-1.9-7.2.1l-.2.2c1.8.1 3.6.9 4.9 2.2zm-28.8 14c.4.9.7 1.9.8 3.1l16.5-16.9c.6-.6 1.4-1.1 2.1-1.5 1-1.9.7-4.4-.9-6-2-1.9-5.2-1.9-7.2.1l-15.5 15.9c2.3 2.2 3.1 3 4.2 5.3zm-38.9 39.7c-.1-8.9 3.2-17.2 9.4-23.6l18.6-19c.7-2 .5-4.1-.1-5.3-.8-1.8-1.3-2.3-3.6-4.5l-20.9 21.4c-10.6 10.8-11.2 27.6-2.3 39.3-.6-2.6-1-5.4-1.1-8.3z"/>
      <path d="M-527.2 399.1l20.9-21.4c2.2 2.2 2.7 2.6 3.5 4.5.8 1.8 1 5.4-1.6 8l-11.8 12.2c-.5.5-.4 1.2 0 1.7.5.5 1.2.5 1.7 0l34-35c1.9-2 5.2-2.1 7.2-.1 2 1.9 2 5.2.1 7.2l-24.7 25.3c-.5.5-.4 1.2 0 1.7.5.5 1.2.5 1.7 0l28.5-29.3c2-2 5.2-2 7.1-.1 2 1.9 2 5.1.1 7.1l-28.5 29.3c-.5.5-.4 1.2 0 1.7.5.5 1.2.4 1.7 0l24.7-25.3c1.9-2 5.1-2.1 7.1-.1 2 1.9 2 5.2.1 7.2l-24.7 25.3c-.5.5-.4 1.2 0 1.7.5.5 1.2.5 1.7 0l14.6-15c2-2 5.2-2 7.2-.1 2 2 2.1 5.2.1 7.2l-27.6 28.4c-11.6 11.9-30.6 12.2-42.5.6-12-11.7-12.2-30.8-.6-42.7m18.1-48.4l-.7 4.9-2.2-4.4m7.6.9l-3.7 3.4 1.2-4.8m5.5 4.7l-4.8 1.6 3.1-3.9"/>
    </svg>
  </span>
                <span #clapCount class="clap--count">+{{currentClaps}}</span>
                <span #clapCountTotal class="clap--count-total"></span>
              </button>

            </div>
          </ion-col>

css

.clap {
    position: relative;
    outline: 1px solid transparent;
    border-radius: 50%;
    border: 1px solid #a750a9;
    width:50px; top:-0.8rem;
    height: 50px; margin: 0px auto; margin-left: 2.3rem;
    background: none;   cursor: pointer;animation: pulse 2s infinite;

  }
  .clap:after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    border-radius: 50%;
    width: 49px;
    height: 49px;
  }
  .clap:hover {
    cursor: pointer;
    border: 1px solid #a750a9;
    transition: border-color 0.3s ease-in;
  }
  .clap:hover:after {
    animation: shockwave 1s ease-in infinite;
  }
  .clap svg {
    width: 30px;
    fill: none;
    stroke: #a750a9;
    stroke-width: 2px;
  }
  .clap svg.checked {
    fill: #a750a9;
    stroke: #a750a9;
    stroke-width: 1px;
  }
  .clap .clap--count {
    position: absolute;
    top: -22px;
    left: 10px;
    font-size: 1.3rem;
    color: white;
    background:#a750a9;
    border-radius: 50%;
    height: 40px;
    width: 40px;
    line-height: 40px;
  }
  .clap .clap--count-total {
    position: absolute;
    font-size: 1.3rem;
    width: 80px;
    text-align: center;
    left: 0;
    top: -22.8571428571px;
    color: #bdc3c7;
  }

.ts

@Input() claps = 0;

  @Input() tlDuration = 300;

  @Output() clapsChange = new EventEmitter();

  @ViewChild('clap') clapEl: ElementRef;

  @ViewChild('clapCount') clapCountEl: ElementRef;

  @ViewChild('clapCountTotal') clapCountTotalEl: ElementRef;

  currentClaps: number = 0;

  clapIconChecked = false;

  private animationTimeline: any;

  private clapHold: any;


  repeatClapping() {
    if (this.currentClaps > 4999) {
      alert('Limit 5000 claps');
      return;
    }

    this.currentClaps++;
    this.claps++;
    this.clapsChange.emit(this.claps);

    this.animationTimeline.replay();
    this.clapIconChecked = true;
  }

  onClapMouseDown() {
    this.clapHold = setInterval(() => {
      this.repeatClapping();
    }, 400);
  }

  onClapMouseUp() {
    clearInterval(this.clapHold);
  }

}

【问题讨论】:

  • 我不清楚你的问题。您是否试图模仿示例中的动画?还是您想修复计数器的错误?
  • @yurzui 先生,这是我过去的问题,它对我有用,但我有一些问题,我在我的应用程序非常慢后添加了 mo.js,我想知道如何创建没有mo.js

标签: angular ionic-framework ionic3


【解决方案1】:

您想要做的基本上是您的应用程序的动画模块。

在示例中,mo.js 用于操作 svg 和 html 对象。

在 Angular 中,您可以使用相同的效果,或者您可以使用 animations 模块重新创建效果。

您也可以在 stackblitz 编辑器中安装 mojs。

【讨论】:

  • 先生,我想不用mo.js我已经准备好安装mo.js,之后我的应用程序很慢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-23
  • 1970-01-01
  • 2018-07-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多