Commit f1ea0484 authored by wangqinghua's avatar wangqinghua

左滑

parent 65b65be3
import { NgModule } from '@angular/core';
import { SlideComponent } from './slide/slide';
import {NgModule} from '@angular/core';
import {SlideComponent} from './slide/slide';
import {IonicPageModule} from "ionic-angular";
import { SlideListComponent } from './slide-list/slide-list';
import {SlideListComponent} from './slide-list/slide-list';
@NgModule({
declarations: [SlideComponent,
SlideListComponent,
......@@ -12,10 +13,11 @@ import { SlideListComponent } from './slide-list/slide-list';
],
exports: [SlideComponent,
SlideListComponent,
],
providers:[
providers: [
SlideComponent,
SlideListComponent,
]
})
export class ComponentsModule {}
export class ComponentsModule {
}
<!--true 隐藏 false 显示-->
<div [hidden]="isScroll" class="news-content">
<div class="tabs-parent">
<div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children">
......@@ -7,6 +8,7 @@
</div>
</div>
<!--固定 false -->
<div [hidden]="!isScroll" ion-fixed class="news-content ion-fixed">
<div class="tabs-parent">
<div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children">
......
import {AfterViewInit, Component, ElementRef, ViewChild} from '@angular/core';
import {Slides} from "ionic-angular";
import {AfterViewInit, Component, ElementRef, NgZone, ViewChild} from '@angular/core';
import {Content, Slides} from "ionic-angular";
import {TabsService} from "../../pages/tabs/tabs.service";
import {AppGlobal} from "../../service/http.service";
......@@ -7,11 +7,11 @@ import {AppGlobal} from "../../service/http.service";
selector: 'slide-list',
templateUrl: 'slide-list.html'
})
export class SlideListComponent implements AfterViewInit{
@ViewChild(Slides) slides:Slides;
@ViewChild('tabSpan') tabSpan:ElementRef;
@ViewChild('tips') tips:ElementRef;
@ViewChild('tips1') tips1:ElementRef;
export class SlideListComponent implements AfterViewInit {
@ViewChild(Slides) slides1: Slides;
@ViewChild('tabSpan') tabSpan: ElementRef;
@ViewChild('tips') tips: ElementRef;
@ViewChild('tips1') tips1: ElementRef;
isScroll = false;
//所属板块类型:
......@@ -28,10 +28,8 @@ export class SlideListComponent implements AfterViewInit{
picture: string = AppGlobal.domain + '/wisdomgroup';
constructor(private tabsSer:TabsService) {
constructor(private tabsSer: TabsService,public zone:NgZone) {
this.slideList.length = 4;
console.log('Hello SlideListComponent Component');
}
ngAfterViewInit(): void {
......@@ -64,19 +62,25 @@ export class SlideListComponent implements AfterViewInit{
e.imgUrl = e.attachments[0].path;
}
})
this.slides.slideTo(index,500);
this.slides1.slideTo(index, 500);
this.slideList[index] = arr;
}
)
}
slideChange(e){
const index = this.slides.getActiveIndex();
// console.log(this.tabsList[index]);
// this.changeParent(this.tabsList[index])
slideChange(e) {
const index = this.slides1.getActiveIndex();
this.change(this.tabsList[index])
}
//判断是否scroll true 滑动 false 不滑动
scroll(bool) {
this.isScroll = bool !== 'false';
console.log(this.isScroll)
}
//
goToDetail(item){}
goToDetail(item) {
}
}
......@@ -7,5 +7,6 @@
</ion-slide>
</ion-slides>
</div>
<p class="slides-title">{{slideTitle}} <span class="main-color" float-end>1<span
<p class="slides-title">
{{slideTitle}} <span class="main-color" float-end>1<span
style="font-size: 1.5rem;font-weight: 400;">/{{slidersItems.length}}</span></span></p>
\ No newline at end of file
......@@ -12,6 +12,7 @@ import {SearchNewPage} from "../../home-pages/search-new/search-new";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
import {EmitService} from "../../../provide/emit.service";
import {DatePipe} from "@angular/common";
import {SlideListComponent} from "../../../components/slide-list/slide-list";
@IonicPage()
@Component({
......@@ -61,7 +62,7 @@ export class HomePage {
constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe,
public commonSer: CommonService, public emitSer: EmitService,
public zone: NgZone,public renderer:Renderer2,
public zone: NgZone,public slideList:SlideListComponent,
public appService: AppService, public http: Http, public storage: Storage,
public badge: Badge, public tabsSer: TabsService) {
// 接收发射过来的数据
......@@ -85,15 +86,17 @@ export class HomePage {
this.getInfo();
this.scrollHeight();
}
scrollHeight(){
const height = this.topHeight.nativeElement.offsetHeight + 80;
this.content.ionScroll.subscribe(($event)=>{
this.zone.run(()=>{
// this.headerTag.nativeElement.
if(this.content.scrollTop > height){
this.isScroll = true;
this.slideList.scroll('true');
}else{
this.isScroll = false;
this.slideList.scroll('false');
}
this.content.resize();
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment