删除第一张和最后一张幻灯片SwiperJS的效果

时间:2016-07-01 04:53:22

标签: slider swiper

我已经将swiper slide与coverflow效果集成在一起,现在我不想要第一张和最后一张幻灯片的效果。我们可以只删除第一个和第一个幻灯片的效果。???

3 个答案:

答案 0 :(得分:0)

您可以检查您的位置并停用"滑动到上一个"当你在第一个标签中时,"滑到下一个"当你在最后一个。像这样,

Context c;
private List<MainActivityLanguagesModel> languages_list;
int positionClass;

public MainActivityLanguagesAdapter(List<MainActivityLanguagesModel> languages_list, Context c) {
    this.languages_list = languages_list;
    this.c = c;
}

@Override
public int getCount() {
    return languages_list.size();
}

@Override
public Object getItem(int position) {
    return languages_list.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}


@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) c
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    if (convertView == null) {
        convertView = inflater.inflate(R.layout.cell_main_grid, parent, false);
    }

    final Button followButton = (Button) convertView.findViewById(R.id.LanguagesCellFollowButton);
    ImageView pictureView = (ImageView) convertView.findViewById(R.id.LanguagesCellPicture);
    TextView title = (TextView) convertView.findViewById(R.id.LanguagesCellTitle);

    Picasso.with(c).load(languages_list.get(position).getImage()).into(pictureView);
    title.setText(languages_list.get(position).getTitle());
    title.setTextColor(Color.WHITE);

    if (languages_list.get(position).getIs_following() == 1)
        followButton.setText("UNFOLLOW");
    else
        followButton.setText("FOLLOW");

    followButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            JSONObject following_Data = new JSONObject();
            try {

                positionClass = position;
                Log.d("positionClass1", String.valueOf(positionClass));

                following_Data.put("token", SessionInfo.login_informations.getToken());
                following_Data.put("lang_id", languages_list.get(position).getId());

            } catch (JSONException e) {
                e.printStackTrace();
            }
            new FollowingTask().execute(following_Data.toString());

        }
    });

    return convertView;
}


class FollowingTask extends AsyncTask<String, String, String> {

    protected void onPreExecute() {
        super.onPreExecute();
    }

    public String doInBackground(String... params) {

        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(
                ServerAddress.server_address + "languages/following");
        httpPost.setHeader("content-type", "application/json");

        StringEntity entity;
        try {
            entity = new StringEntity(params[0], HTTP.UTF_8);
            httpPost.setEntity(entity);
        } catch (Exception e) {
            e.printStackTrace();
        }

        HttpResponse response;
        final String petsResult;
        try {
            response = httpClient.execute(httpPost);
            HttpEntity responseEntity = response.getEntity();
            petsResult = EntityUtils.toString(responseEntity);

        } catch (IOException e) {
            e.printStackTrace();
            return e.getMessage();
        }

        Log.d("petsResultString", petsResult.toString());
        try {
            JSONObject json = new JSONObject(petsResult);

            int status = 0;
            if (json.isNull("er") && json.getInt("e") == 0) {
                JSONObject data = json.getJSONObject("d");
                status = data.getInt("status");
            }

            return String.valueOf(status);

        } catch (JSONException e) {
            e.printStackTrace();
            return e.getMessage();
        }
    }

    public void onPostExecute(String result) {

        Log.d("isFollow", String.valueOf(result));

        if (languages_list.get(positionClass).getIs_following() == 1)
            languages_list.get(positionClass).setIs_following(0);
        else
            languages_list.get(positionClass).setIs_following(1);

        notifyDataSetChanged();

    }

}

答案 1 :(得分:0)

我猜你的意思是slideShadows属性。如果是这样,您可以轻松地显示/隐藏它,如下所示:

var mySwiper = new Swiper('.swiper-container', {
  coverflowEffect: {
    rotate: 30,
    slideShadows: false,
  },
});

答案 2 :(得分:0)

我正在通过 CSS 修复超链接状态,如下例所示,它工作正常。

.swiper-slide a {
    pointer-events: none !important;
}
.swiper-slide.swiper-slide-next a {
    pointer-events: unset !important;
}